Skip to content

Commit

Permalink
dockerfile-improve
Browse files Browse the repository at this point in the history
  • Loading branch information
nstankov-bg committed Jul 22, 2023
1 parent 8f03bf1 commit cdac0bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ cmd/oaevals-collector/processed/
*.md

# ignore all docker compose files
docker-compose.*
docker/docker-compose.*
16 changes: 6 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@ RUN go mod download
# This is the "cache busting" step.
COPY . .

ARG CORES=4

# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./
RUN CGO_ENABLED=0 GOOS=linux go build -o main -p ${CORES} ./

# Start a new stage from scratch
FROM gcr.io/distroless/base-debian11

# Set the Current Working Directory inside the container
WORKDIR /root/

# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app/main .
COPY --from=builder /app/main /root/main

# Command to run the executable
# Set the working directory and the entrypoint
WORKDIR /root/
ENTRYPOINT ["./main"]

# As a best practice, we don't EXPOSE the port in the Dockerfile, as it can lead to
# misunderstandings about the function of the EXPOSE directive. The port binding should
# be specified at runtime using the -p flag.

0 comments on commit cdac0bb

Please sign in to comment.