🐳 updated Dockerfile for folder structure

Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
haraldnilsen 2024-01-13 12:00:42 +01:00
parent 98f25c1b32
commit 6f1db8b64a

View file

@ -1,25 +1,18 @@
# syntax=docker/dockerfile:1
# Start from the latest golang base image # Start from the latest golang base image
FROM golang:latest AS build FROM golang:latest
# Set the Current Working Directory inside the container # Set the Current Working Directory inside the container
WORKDIR /app WORKDIR /app
# Copy everything from the current directory to the PWD inside the container # Copy everything from the current directory to the PWD inside the container
COPY . . COPY go.* .
# Download all the dependencies # Download all the dependencies
RUN go mod download RUN go mod download && go mod verify
# Build the Go app - change directory to 'cmd' where main.go resides COPY ./cmd ./cmd
RUN go build -o /app/hello ./cmd
FROM alpine:latest RUN go build -v -o main ./cmd
WORKDIR /app
COPY --from=build /app/hello .
# Command to run the executable # Command to run the executable
CMD ["./hello"] CMD ["./main"]