From 4b66b7a2fa9b6d058fa94ff7ba19133ccb44b537 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Fri, 23 Dec 2022 01:54:03 +0100 Subject: [PATCH] Add Dockerfile(s) for frontend and backend, renamed the existing one to Dockerfile.embedded --- Dockerfile.backend | 22 ++++++++++++++++++++++ Dockerfile => Dockerfile.embedded | 0 Dockerfile.frontend | 16 ++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 Dockerfile.backend rename Dockerfile => Dockerfile.embedded (100%) create mode 100644 Dockerfile.frontend diff --git a/Dockerfile.backend b/Dockerfile.backend new file mode 100644 index 0000000..150ca4b --- /dev/null +++ b/Dockerfile.backend @@ -0,0 +1,22 @@ +FROM golang:1.19.1 AS builder + +### Copy Go code +WORKDIR /src/ +COPY . . + +### Build executables +RUN go build -o /app/webapi ./cmd/webapi + + +### Create final container +FROM debian:bullseye + +### Inform Docker about which port is used +EXPOSE 3000 4000 + +### Copy the build executable from the builder image +WORKDIR /app/ +COPY --from=builder /app/webapi ./ + +### Executable command +CMD ["/app/webapi"] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile.embedded similarity index 100% rename from Dockerfile rename to Dockerfile.embedded diff --git a/Dockerfile.frontend b/Dockerfile.frontend new file mode 100644 index 0000000..28608b4 --- /dev/null +++ b/Dockerfile.frontend @@ -0,0 +1,16 @@ +FROM node:lts as builder + +### Copy Vue.js code +WORKDIR /app +COPY webui webui + +### Build Vue.js into plain HTML/CSS/JS +WORKDIR /app/webui +RUN npm run build-prod + + +### Create final container +FROM nginx:stable + +### Copy the (built) app from the builder image +COPY --from=builder /app/webui/dist /usr/share/nginx/html \ No newline at end of file