Replace stored procedure calls with inline INSERT statements and SCOPE_IDENTITY() Add netcat for readiness check in new entrypoint.sh Introduce dedicated SQL Server and init-db services in docker-compose
39 lines
811 B
Docker
39 lines
811 B
Docker
# 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
|
|
RUN apk add --no-cache netcat-openbsd
|
|
|
|
# Set workdir
|
|
WORKDIR /app
|
|
# Removed hosts entry addition (handled via docker-compose extra_hosts)
|
|
|
|
# Copy the binary from the builder stage
|
|
COPY --from=builder /app/main .
|
|
|
|
# Expose the application port (default for the Go server)
|
|
COPY entrypoint.sh .
|
|
RUN chmod +x entrypoint.sh
|
|
EXPOSE 8080
|
|
|
|
# Command to run the binary
|
|
CMD ["./entrypoint.sh"]
|