38 lines
898 B
Docker
38 lines
898 B
Docker
# Use a small Go base image
|
|
FROM golang:1.24 AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /root
|
|
|
|
# Copy go mod and sum files
|
|
COPY ../go.mod ../go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy the rest of the application
|
|
COPY ../src/ ./src/
|
|
COPY ../scripts/ ./scripts/
|
|
RUN chmod +x /root/scripts/startup.sh
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o harbormaster ./src/
|
|
|
|
# Use a small base image for the final container
|
|
FROM alpine:latest
|
|
|
|
# Set working directory
|
|
WORKDIR /root
|
|
|
|
# Copy the compiled binary from the builder stage
|
|
COPY --from=builder /root/harbormaster .
|
|
#COPY database/gold.db /root/database/gold.db
|
|
#COPY migrations /root/migrations
|
|
COPY ../scripts/ ./scripts/
|
|
RUN chmod +x /root/scripts/startup.sh
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 8080
|
|
|
|
# Run database setup and the binary
|
|
CMD ["/bin/ash", "-c", "/root/scripts/startup.sh"] |