file_system/Dockerfile

35 lines
757 B
Docker

# Build Stage
FROM 192.168.1.154:31010/golang:1.23-alpine AS builder
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Copy the source from the current directory to the Working Directory inside the container
COPY . .
# Build the Go app
RUN go build -o server ./cmd/server
# Run Stage
FROM alpine:latest
WORKDIR /app
# Copy the Pre-built binary from the previous stage
COPY --from=builder /app/server .
# Copy web resources
COPY --from=builder /app/web ./web
# Copy docs
COPY --from=builder /app/docs ./docs
# Expose port 8080 to the outside world
EXPOSE 8080
# Command to run the executable
CMD ["./server"]