Merge pull request 'add and test dockerfile build and run' (#1) from DockerizeAPI into main
Reviewed-on: https://gitea.donovankelly.dev/dkelly/go-nkode/pulls/1
This commit is contained in:
41
Dockerfile
Normal file
41
Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Stage 1: Build
|
||||||
|
FROM golang:1.23 AS builder
|
||||||
|
|
||||||
|
# Set the working directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# volume for nkode.db
|
||||||
|
VOLUME /app/data/sqlite
|
||||||
|
VOLUME /app/data/icons
|
||||||
|
|
||||||
|
# Copy go.mod and go.sum files
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
# Download all dependencies
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Copy the rest of the application code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the application
|
||||||
|
RUN go build
|
||||||
|
|
||||||
|
# Stage 2: Runtime
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
|
#ENV FRONTEND_HOST=https://app.nkode.tech
|
||||||
|
ENV FRONTEND_HOST=http://localhost:8090
|
||||||
|
ENV SVG_DIR=/app/data/icons
|
||||||
|
ENV DB_PATH=/app/data/sqlite/nkode.db
|
||||||
|
ENV SQLITE_DB=/app/data/sqlite/nkode.db
|
||||||
|
# Set the working directory inside the runtime container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the compiled Go binary from the builder stage
|
||||||
|
COPY --from=builder /app/go-nkode .
|
||||||
|
|
||||||
|
# Expose the port the application will run on
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Command to run the application
|
||||||
|
CMD ["./go-nkode"]
|
||||||
16
README.md
16
README.md
@@ -1 +1,15 @@
|
|||||||
test edit
|
# Go nKode
|
||||||
|
|
||||||
|
A golang implementation of nKode
|
||||||
|
|
||||||
|
## env var
|
||||||
|
|
||||||
|
```.env
|
||||||
|
|
||||||
|
LOCAL=true # todo: remove this
|
||||||
|
FRONTEND_HOST=https://app.nkode.tech # localhost:8080
|
||||||
|
SVG_DIR=/path/to/go-nkode/core/sqlite-init/flaticon_colored_svgs
|
||||||
|
DB_PATH=/path/to/nkode.db # todo: remove this
|
||||||
|
SQLITE_DB=/path/to/nkode.db
|
||||||
|
JWT_SECRET= # openssl rand -base64 64
|
||||||
|
```
|
||||||
1
docker_build.sh
Normal file
1
docker_build.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
docker build -t go-nkode .
|
||||||
5
docker_run.sh
Normal file
5
docker_run.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
docker run --name go-nkode -p 8080:8080 \
|
||||||
|
-v /Users/donov/databases/:/app/data/sqlite \
|
||||||
|
-v /Users/donov/Desktop/go-nkode/core/sqlite-init/flaticon_colored_svgs/:/app/data/icons \
|
||||||
|
-e JWT_SECRET=cab2f6a968c2a11601bb33c41c5940b7 \
|
||||||
|
go-nkode
|
||||||
2
main.go
2
main.go
@@ -40,7 +40,7 @@ func main() {
|
|||||||
mux.Handle(core.RefreshToken, &handler)
|
mux.Handle(core.RefreshToken, &handler)
|
||||||
mux.Handle(core.ResetNKode, &handler)
|
mux.Handle(core.ResetNKode, &handler)
|
||||||
fmt.Println("Running on localhost:8080...")
|
fmt.Println("Running on localhost:8080...")
|
||||||
log.Fatal(http.ListenAndServe("localhost:8080", corsMiddleware(mux)))
|
log.Fatal(http.ListenAndServe(":8080", corsMiddleware(mux)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func corsMiddleware(next http.Handler) http.Handler {
|
func corsMiddleware(next http.Handler) http.Handler {
|
||||||
|
|||||||
Reference in New Issue
Block a user