Add Docker Compose and backend Dockerfile
Include .gitignore, go.mod/go.sum, initial Go source, init.sql, and Docker‑Compose configuration for the MSSQL and backend services.
This commit is contained in:
34
backend/Dockerfile
Normal file
34
backend/Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
# Use the official Go image as the base image
|
||||
FROM golang:1.22-alpine AS builder
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Cache Go modules
|
||||
COPY go.mod ./
|
||||
RUN apk add --no-cache git
|
||||
RUN go mod download
|
||||
|
||||
# Copy the source code
|
||||
COPY . .
|
||||
|
||||
# Build the Go binary
|
||||
RUN go build -o main .
|
||||
|
||||
# ---- Runtime image ----
|
||||
FROM alpine:3.19
|
||||
|
||||
# Install ca-certificates (if needed)
|
||||
RUN apk add --no-cache ca-certificates
|
||||
|
||||
# Set workdir
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the binary from the builder stage
|
||||
COPY --from=builder /app/main .
|
||||
|
||||
# Expose the application port (default for the Go server)
|
||||
EXPOSE 8080
|
||||
|
||||
# Command to run the binary
|
||||
CMD ["./main"]
|
||||
Reference in New Issue
Block a user