build: add Docker deployment
Created a Dockerfile and nginx configuration and added environment variables into the codebase to support Docker compose. ref: N25B-282
This commit is contained in:
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
# --- Building static files ---
|
||||
FROM node:23-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
|
||||
# --- Serving ---
|
||||
FROM nginx:alpine
|
||||
|
||||
RUN mkdir -p /app/www
|
||||
|
||||
COPY --from=build /app/dist /app/www
|
||||
|
||||
COPY nginx.conf /etc/nginx/templates/default.conf.template
|
||||
|
||||
RUN adduser -D -H -u 1001 -s /sbin/nologin webuser
|
||||
|
||||
RUN chown -R webuser:webuser /app/www && \
|
||||
chmod -R 755 /app/www && \
|
||||
chown -R webuser:webuser /var/cache/nginx && \
|
||||
chown -R webuser:webuser /var/log/nginx && \
|
||||
chown -R webuser:webuser /etc/nginx/conf.d && \
|
||||
touch /var/run/nginx.pid && \
|
||||
chown -R webuser:webuser /var/run/nginx.pid && \
|
||||
chmod -R 777 /etc/nginx/conf.d
|
||||
|
||||
ENV PORT=80
|
||||
ENV NGINX_ENVSUBST_TEMPLATE_DIR=/etc/nginx/templates
|
||||
ENV NGINX_ENVSUBST_TEMPLATE_SUFFIX=.template
|
||||
ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/conf.d
|
||||
# Default value, potentially overwritten in compose file
|
||||
ENV BACKEND_ADDRESS="http://localhost:8000"
|
||||
|
||||
EXPOSE ${PORT}
|
||||
|
||||
USER webuser
|
||||
|
||||
CMD [ "nginx", "-g", "daemon off;" ]
|
||||
Reference in New Issue
Block a user