radames's picture
radames HF staff
first
2af848d
# See https://hub.docker.com/r/nikolaik/python-nodejs
# https://github.com/nikolaik/docker-python-nodejs
# Default user is 'pn' with uid 1000, gid 1000
FROM nikolaik/python-nodejs:python3.10-nodejs18
# Install nginx and give permissions to 'pn'
# See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/
USER root
RUN apt-get -y update && apt-get -y install nginx
RUN mkdir -p /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx
RUN touch /var/run/nginx.pid
RUN chown -R pn:pn /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx \
/var/run/nginx.pid
# Install dependencies and build app as non-root
USER pn
ENV HOME=/home/pn \
PATH=/home/pn/.local/bin:$PATH
RUN mkdir $HOME/app
WORKDIR $HOME/app
COPY --chown=pn requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy nginx configuration
COPY --chown=pn nginx.conf /etc/nginx/sites-available/default
COPY --chown=pn . .
CMD ["bash", "run.sh"]