luminlab-adapt/nginx
0
1# See https://hub.docker.com/r/nikolaik/python-nodejs2# https://github.com/nikolaik/docker-python-nodejs3# Default user is 'luminlab' with uid 1000, gid 10004FROM nikolaik/python-nodejs:python3.10-nodejs185 6# Install nginx and give permissions to 'luminlab'7# See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/8USER root9 10RUN apt-get -y update && apt-get -y install nginx11 12RUN mkdir -p /var/cache/nginx \13 /var/log/nginx \14 /var/lib/nginx15RUN touch /var/run/nginx.pid16 17RUN chown -R luminlab:luminlab /var/cache/nginx \18 /var/log/nginx \19 /var/lib/nginx \20 /var/run/nginx.pid21 22# syntax=docker/dockerfile:1.423 24# 1. For build React app25FROM node:lts AS development26 27# Set working directory28WORKDIR /app29 30# 31COPY package.json /app/package.json32COPY package-lock.json /app/package-lock.json33 34# Same as npm install35RUN npm ci36 37COPY . /app38 39ENV CI=true40ENV PORT=300041 42CMD [ "npm", "start" ]43 44FROM development AS build45 46RUN npm run build47 48 49FROM development as dev-envs50RUN apt-get update &&\51 apt-get install -y --no-install-recommends git52 53RUN useradd -s /bin/bash -m vscode &&\54 groupadd docker &&\55 usermod -aG docker vscode 56 57# install Docker tools (cli, buildx, compose)58COPY --from=gloursdocker/docker / /59CMD [ "npm", "start" ]60 61# 2. For Nginx setup62FROM nginx:alpine63 64# Copy config nginx65COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf66 67WORKDIR /usr/share/nginx/html68 69# Remove default nginx static assets70RUN rm -rf ./*71 72# Copy static assets from builder stage73COPY --from=build /app/build .74 75# # Containers run nginx with global directives and daemon off76ENTRYPOINT ["nginx", "-g", "daemon off;"]77 78 79# Install dependencies and build app as non-root80# USER luminlab81# ENV HOME=/home/luminlab \82# PATH=/home/luminlab/.local/bin:$PATH83 84# RUN mkdir $HOME/app85 86# WORKDIR $HOME/app87 88# COPY --chown=pn requirements.txt requirements.txt89# RUN pip install --no-cache-dir -r requirements.txt90 91# # Copy nginx configuration92# COPY --chown=luminlab nginx.conf /etc/nginx/sites-available/default93 94# COPY --chown=luminlab . .95 96# CMD ["bash", "run.sh"]