🐳 updated Dockerfile

This commit is contained in:
haraldnilsen 2024-01-12 22:01:59 +01:00
parent ee348a9bd4
commit 2f7536310c

View file

@ -1,27 +1,22 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
# Start from the latest golang base image
FROM golang:latest FROM golang:latest
# Set destination for COPY # Set the Current Working Directory inside the container
WORKDIR /app WORKDIR /app
# Download Go modules # Copy everything from the current directory to the PWD inside the container
COPY go.mod go.sum ./ COPY . .
# Download all the dependencies
RUN go mod download RUN go mod download
# Copy the source code. Note the slash at the end, as explained in # Build the Go app - change directory to 'cmd' where main.go resides
# https://docs.docker.com/engine/reference/builder/#copy RUN go build -o main ./cmd
COPY *.go ./
# Build # Expose port 8080 to the outside world
RUN CGO_ENABLED=0 GOOS=linux go build -o /docker-gs-ping
# Optional:
# To bind to a TCP port, runtime parameters must be supplied to the docker command.
# But we can document in the Dockerfile what ports
# the application is going to listen on by default.
# https://docs.docker.com/engine/reference/builder/#expose
EXPOSE 8080 EXPOSE 8080
# Run # Command to run the executable
CMD ["/docker-gs-ping"] CMD ["./main"]