From 006fe93d08d9c5e0cb0e2705edaad064f609e914 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Fri, 12 Jan 2024 22:30:39 +0100 Subject: [PATCH] :whale: updated dockerfile --- backend/Dockerfile | 13 ++++++++----- backend/docker-compose.yml | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index d15584d..53c4326 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # Start from the latest golang base image -FROM golang:latest +FROM golang:latest AS build # Set the Current Working Directory inside the container WORKDIR /app @@ -13,10 +13,13 @@ COPY . . RUN go mod download # Build the Go app - change directory to 'cmd' where main.go resides -RUN go build -o main ./cmd +RUN go build -o /app/hello -# Expose port 8080 to the outside world -EXPOSE 8080 +FROM alpine:latest + +WORKDIR /app + +COPY --from=build /app/hello . # Command to run the executable -CMD ["./cmd/main"] +CMD ["./hello"] diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index edae88d..a8db177 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -16,7 +16,7 @@ services: context: . dockerfile: Dockerfile ports: - - 8000:8000 + - 8080:8080 image: helseveileder depends_on: - postgres