run migrations when deploying container
This commit is contained in:
19
Dockerfile
19
Dockerfile
@@ -5,6 +5,14 @@ ENV CGO_ENABLED=0
|
||||
ENV GOOS=linux
|
||||
ENV GOARCH=amd64
|
||||
|
||||
# Install goose
|
||||
WORKDIR /goose.git
|
||||
|
||||
RUN git clone https://github.com/pressly/goose.git .
|
||||
RUN go build -tags='no_clickhouse no_libsql no_mssql no_mysql no_sqlite3 no_vertica no_ydb' \
|
||||
-o goose ./cmd/goose
|
||||
|
||||
# Build app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the Go modules and dependencies
|
||||
@@ -20,22 +28,17 @@ COPY ./src/internal ./internal
|
||||
RUN go build -o main cmd/frontend/*
|
||||
|
||||
|
||||
# --- Stage 2: Run the application ---
|
||||
# --- Stage 3: Run the application ---
|
||||
FROM alpine:latest
|
||||
|
||||
ENV DB_HOST="10.99.0.3"
|
||||
ENV DB_PORT="5432"
|
||||
ENV DB_NAME="crowsnest"
|
||||
ENV DB_USER="crow"
|
||||
ENV DB_PASS=""
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built binary from the builder stage
|
||||
COPY --from=builder /app/main .
|
||||
COPY --from=builder /goose.git/goose .
|
||||
COPY ./src/assets ./assets
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
# Command to run the application
|
||||
CMD ["/app/main"]
|
||||
CMD ["sh", "-c", "/app/goose -dir=/app/assets/migrations/ postgres postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT/$DB_NAME up && /app/main"]
|
||||
|
||||
Reference in New Issue
Block a user