Migrations the right way

This commit is contained in:
PB
2025-11-08 17:54:22 +01:00
parent bceaa010ab
commit fc6970adc2
9 changed files with 88 additions and 266 deletions

View File

@@ -2,14 +2,14 @@
FROM golang:alpine
ARG BIN_OUTPUT=/go/bin
ARG GO_SERVER=cmd/server/main.go
ARG GO_CHRONOS=cmd/scheduler/main.go
ARG GO_MIGRATE=cmd/migrate/main.go
ARG GO_SCHEDULER=cmd/scheduler/main.go
ARG GO_SERVER=cmd/server/main.go
WORKDIR /go/src/app
COPY src/ ./
RUN export CGO_ENABLED=0 ; export GOOS=linux ; export GOARCH=amd64 && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/server" $GO_SERVER && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/scheduler" $GO_CHRONOS && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/migrate" $GO_MIGRATE
go build -ldflags="-w -s" -o "$BIN_OUTPUT/migrate" $GO_MIGRATE && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/scheduler" $GO_SCHEDULER && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/server" $GO_SERVER

View File

@@ -18,16 +18,16 @@ LABEL dev.egommerce.image.build_time=${BUILD_TIME}
WORKDIR /
COPY --from=builder /go/bin/server /usr/local/bin/server
COPY --from=builder /go/bin/migrate /usr/local/bin/migrate
COPY --from=builder /go/bin/scheduler /usr/local/bin/scheduler
COPY --from=builder /go/bin/server /usr/local/bin/server
COPY deploy/.env.docker /.env
COPY ./bin/* /usr/local/bin/
RUN chmod 755 /usr/local/bin/entrypoint.sh /usr/local/bin/migrate.sh
RUN chmod 755 /usr/local/bin/entrypoint /usr/local/bin/migrate
EXPOSE 443
ENTRYPOINT ["entrypoint.sh"]
ENTRYPOINT ["entrypoint"]
CMD ["sh", "-c", "/usr/local/bin/server"]