diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..944c04e --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/README.md b/README.md index c9e9eaf..009e681 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ -test edit \ No newline at end of file +# 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 +``` \ No newline at end of file diff --git a/docker_build.sh b/docker_build.sh new file mode 100644 index 0000000..55acca3 --- /dev/null +++ b/docker_build.sh @@ -0,0 +1 @@ +docker build -t go-nkode . \ No newline at end of file diff --git a/docker_run.sh b/docker_run.sh new file mode 100644 index 0000000..236e43e --- /dev/null +++ b/docker_run.sh @@ -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 \ No newline at end of file diff --git a/main.go b/main.go index 3cd15cf..4299b89 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ func main() { mux.Handle(core.RefreshToken, &handler) mux.Handle(core.ResetNKode, &handler) 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 {