2024-02-18 10:42:21 +00:00
|
|
|
# Build Stage
|
2024-08-27 20:36:38 +00:00
|
|
|
FROM golang:1.23.0-alpine AS builder
|
|
|
|
|
2024-02-18 10:42:21 +00:00
|
|
|
# Set environment variable
|
|
|
|
ENV APP_NAME niki
|
|
|
|
|
|
|
|
# Add a work directory
|
|
|
|
WORKDIR /$APP_NAME
|
|
|
|
|
|
|
|
# Copy app files
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
# Budild application
|
2024-08-29 03:26:59 +00:00
|
|
|
RUN CGO_ENABLED=0 go build -mod=vendor -v -o $APP_NAME .
|
2024-02-18 10:42:21 +00:00
|
|
|
|
|
|
|
# Run Stage
|
2024-08-27 20:36:38 +00:00
|
|
|
FROM alpine:3.20 AS runtime
|
2024-02-18 10:42:21 +00:00
|
|
|
|
2024-08-27 20:36:38 +00:00
|
|
|
# Copy the binary from the builder stage
|
|
|
|
COPY --from=builder /niki/niki .
|
|
|
|
|
|
|
|
# Copy migration files
|
|
|
|
COPY --from=builder /niki/repository/mysql/migration ./repository/mysql/migration
|
2024-02-18 10:42:21 +00:00
|
|
|
|
|
|
|
# Expose application port
|
2024-08-29 03:26:59 +00:00
|
|
|
EXPOSE 8313
|
2024-08-27 20:36:38 +00:00
|
|
|
|
|
|
|
# Start the application
|
|
|
|
CMD ["./niki", "--migrate"]
|