From 6f1db8b64aa4e393821d36552ce5683aa7e46b11 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Sat, 13 Jan 2024 12:00:42 +0100 Subject: [PATCH] :whale: updated Dockerfile for folder structure Co-authored-by: Sindre Kjelsrud --- backend/Dockerfile | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 99daaed..7f9c106 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,25 +1,18 @@ -# syntax=docker/dockerfile:1 - # Start from the latest golang base image -FROM golang:latest AS build +FROM golang:latest # Set the Current Working Directory inside the container WORKDIR /app # Copy everything from the current directory to the PWD inside the container -COPY . . +COPY go.* . # 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 -RUN go build -o /app/hello ./cmd +COPY ./cmd ./cmd -FROM alpine:latest - -WORKDIR /app - -COPY --from=build /app/hello . +RUN go build -v -o main ./cmd # Command to run the executable -CMD ["./hello"] +CMD ["./main"]