From 723f335f0fdcfa890137e8500a4b07b27bdeb0d0 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Mon, 7 Jul 2025 16:14:47 +0300 Subject: [PATCH] Feat: add dockerfile --- Dockerfile | 20 ++++++++++++++++++++ Makefile | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8493ea7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Build stage +FROM golang:1.24-alpine AS builder +WORKDIR /src +RUN apk add --no-cache build-base gcc +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=1 GOOS=linux go build -a -o /gralias . + +# Final stage +FROM alpine:latest +WORKDIR /app +COPY --from=builder /gralias /app/gralias +# copy assets and templates +COPY assets ./assets +COPY components ./components +COPY config.example.toml ./config.toml +COPY migrations ./migrations +EXPOSE 3000 +CMD ["/app/gralias"] diff --git a/Makefile b/Makefile index 1e2ea90..74d188f 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,8 @@ stop-container: docker rm -f gralias 2>/dev/null && echo "old container removed" run-container: stop-container - docker run --name=gralias -v $(CURDIR)/store.json:/root/store.json -p 0.0.0.0:3000:3000 -d gralias:master + migrate -database 'sqlite3://gralias.db' -path migrations up + docker run --name=gralias -v $(CURDIR)/gralias.db:/app/gralias.db -p 0.0.0.0:3000:3000 -d gralias:master migrate-up: migrate -database 'sqlite3://gralias.db' -path migrations up