From 57c8648fea65ebbe7519444ef3bd862330b83c78 Mon Sep 17 00:00:00 2001 From: Dmytro Bondar Date: Sat, 21 Sep 2024 19:11:45 +0200 Subject: [PATCH] Update Dockerfile - Fix FromAsCasing - Copy `cmd` and `internal` directories only for backend --- .dockerignore | 19 ++++++++++++++----- Dockerfile | 9 +++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.dockerignore b/.dockerignore index de25823..4308f49 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,14 @@ -.github/ -**/.vscode/ -docs/ -frontend/node_modules/ -internal/app/api/core/frontend-dist +# Ignore everything +* + +# Allow backend files +!cmd/ +!internal/ +!go.mod +!go.sum + +# Allow frontend files +!frontend/ + +# Ignore node_modules +**/node_modules/ diff --git a/Dockerfile b/Dockerfile index 4ec66eb..d23845e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ###### # Build frontend ###### -FROM --platform=${BUILDPLATFORM} node:lts-alpine as frontend +FROM --platform=${BUILDPLATFORM} node:lts-alpine AS frontend # Set the working directory WORKDIR /build # Download dependencies @@ -20,14 +20,15 @@ RUN npm run build ###### # Build backend ###### -FROM --platform=${BUILDPLATFORM} golang:1.22-alpine as builder +FROM --platform=${BUILDPLATFORM} golang:1.22-alpine AS builder # Set the working directory WORKDIR /build # Download dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the sources to the working directory -COPY . . +COPY ./cmd ./cmd +COPY ./internal ./internal # Copy the frontend build result COPY --from=frontend /build/dist/ ./internal/app/api/core/frontend-dist/ # Set the build version from arguments @@ -47,7 +48,7 @@ FROM alpine:3.19 # Install OS-level dependencies RUN apk add --no-cache bash curl iptables nftables openresolv # Setup timezone -ENV TZ=Europe/Vienna +ENV TZ=UTC # Copy binaries COPY --from=builder /build/dist/wg-portal /app/wg-portal # Set the Current Working Directory inside the container