diff --git a/Containerfile b/Containerfile index 6d2ed5c..6c1d819 100644 --- a/Containerfile +++ b/Containerfile @@ -1,3 +1,36 @@ +# Stage 1: Build +FROM golang:1.23 AS builder + +# Set the working directory in the container +WORKDIR /app + +# Copy go.mod and go.sum files +COPY go.mod go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy the entire project +COPY . . + +# Build the Go application +RUN CGO_ENABLED=0 GOOS=linux go build -o service ./cmd/maps-service/service.go + +# Stage 2: Run FROM alpine -COPY build/server / -ENTRYPOINT ["/server"] \ No newline at end of file + +# Set up a non-root user for security +RUN addgroup -S appgroup && adduser -S appuser -G appgroup +USER appuser + +# Set the working directory in the container +WORKDIR /home/appuser + +# Copy the built application from the builder stage +COPY --from=builder /app/service . + +# Expose application port (adjust if needed) +EXPOSE 8081 + +# Command to run the application +CMD ["./service"] diff --git a/compose.yaml b/compose.yaml index 42863c3..e312f66 100644 --- a/compose.yaml +++ b/compose.yaml @@ -7,16 +7,24 @@ services: nats: image: docker.io/nats:latest container_name: nats + command: ["-js"] networks: - maps-service-network + ports: + - "4222:4222" maps-service: build: context: . dockerfile: Containerfile container_name: maps-service + command: ["--debug","serve","--pg-host","10.0.0.29","--pg-port","5432","--pg-db","maps","--pg-user","quat","--pg-password","happypostgresuser","--port","8081","--auth-rpc-host","localhost:8090","--nats-host","0.0.0.0:4222"] + depends_on: + - nats networks: - maps-service-network + ports: + - "8081:8081" web: build: @@ -24,11 +32,15 @@ services: dockerfile: Containerfile networks: - maps-service-network + ports: + - "3000:3000" validation: build: context: validation dockerfile: Containerfile container_name: validation + depends_on: + - nats networks: - maps-service-network