support db migrations

This commit is contained in:
Aleksandr Trushkin
2024-08-13 13:15:11 +03:00
parent 880f67aa73
commit 30e5968e03
11 changed files with 163 additions and 9 deletions

View File

@ -0,0 +1,25 @@
FROM golang:1.22-alpine as golang
ARG VERSION="unknown"
ARG REVISION="unknown"
ARG BUILDTIME=""
WORKDIR /go/src/git.loyso.art/frx/devsim
COPY . .
RUN go mod download && \
go mod verify && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-o /go/bin/migrator /go/src/git.loyso.art/frx/devsim/cmd/migrator/main.go
FROM gcr.io/distroless/static-debian12@sha256:ce46866b3a5170db3b49364900fb3168dc0833dfb46c26da5c77f22abb01d8c3
WORKDIR /app
COPY --from=golang /go/bin/migrator /app/migrator
COPY assets/db/migrations/ /app/db/migrations/
ENV DEVSIM_PG_MIGRATOR="/app/migrations"
ENTRYPOINT ["/app/migrator"]

24
dockers/web/Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM golang:1.22-alpine as golang
ARG VERSION="unknown"
ARG REVISION="unknown"
ARG BUILDTIME=""
WORKDIR /go/src/git.loyso.art/frx/devsim
COPY . .
RUN go mod download && \
go mod verify && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w -s -X 'git.loyso.art/frx/devsim.Version=${VERSION}' -X 'git.loyso.art/frx/devsim.Revision=${REVISION}' -X 'git.loyso.art/frx/devsim.BuildTime=${BUILDTIME}'" \
-o /go/bin/app /go/src/git.loyso.art/frx/devsim/cmd/web/main.go
FROM gcr.io/distroless/static-debian12@sha256:ce46866b3a5170db3b49364900fb3168dc0833dfb46c26da5c77f22abb01d8c3
WORKDIR /app
COPY --from=golang /go/bin/app /app/web
ENV DEVSIM_HTTP_ADDR=":80"
EXPOSE 80
ENTRYPOINT ["/app/web"]