From c450ac2903f56ee03586f7fa5b8f88b2cbd32069 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Fri, 31 Jul 2026 23:45:42 +0500 Subject: [PATCH] add docker prod build --- .build/prod/.env.example | 6 ++++++ .build/prod/Dockerfile | 12 ++++++++++++ .build/prod/README.md | 16 ++++++++++++++++ .build/prod/compose.yml | 9 +++++++++ 4 files changed, 43 insertions(+) create mode 100644 .build/prod/.env.example create mode 100644 .build/prod/Dockerfile create mode 100644 .build/prod/README.md create mode 100644 .build/prod/compose.yml diff --git a/.build/prod/.env.example b/.build/prod/.env.example new file mode 100644 index 0000000..b048913 --- /dev/null +++ b/.build/prod/.env.example @@ -0,0 +1,6 @@ +VITE_API_TARGET=http://localhost:8080/ + +# Base path the client calls. Leave as /api to use the dev proxy (same-origin, +# no CORS). For a production build served on a different origin than the API, +# set this to the API's absolute URL, e.g. https://radapi.example.com +VITE_API_BASE=/api diff --git a/.build/prod/Dockerfile b/.build/prod/Dockerfile new file mode 100644 index 0000000..9456e9b --- /dev/null +++ b/.build/prod/Dockerfile @@ -0,0 +1,12 @@ +FROM node:22.17.0-alpine AS frontendbuilder + +ARG VITE_API_TARGET + +WORKDIR /var/www/html +COPY . . +RUN echo VITE_API_TARGET=$VITE_API_TARGET > .env \ + && npm ci && npm run build + +FROM nginx + +COPY --from=frontendbuilder /var/www/html/dist /usr/share/nginx/html diff --git a/.build/prod/README.md b/.build/prod/README.md new file mode 100644 index 0000000..3735302 --- /dev/null +++ b/.build/prod/README.md @@ -0,0 +1,16 @@ + +## Production deployment +it is assumed that you will be using backend on the same machine, so this compose is for both services +```yml +services: + frontend: + hostname: frontend + image: git.shihaam.dev/sarlink/radui + ports: + - 8000:80 + backend: + hostname: backend + image: git.shihaam.dev/sarlink/radapi + ports: + - 8001:80 +``` diff --git a/.build/prod/compose.yml b/.build/prod/compose.yml new file mode 100644 index 0000000..884f720 --- /dev/null +++ b/.build/prod/compose.yml @@ -0,0 +1,9 @@ +services: + frontend: + build: + context: ../../ + dockerfile: .build/prod/Dockerfile + args: + VITE_API_TARGET: ${VITE_API_TARGET} + hostname: frontend + image: git.shihaam.dev/sarlink/radui