docker build
Docker build is not optimal. From !313 (merged)
This looks like it should work just fine, but is not yet optimal - the resulting container would contain nodejs binaries which are not really required for the operation of the application (we only care about the front-end libraries which are fetch by
npm install
).The way to solve that is to use multi-stage builds: https://docs.docker.com/develop/develop-images/multistage-build/
In essence it's splitting a container into two (or more) - first one could be based on nodejs image and would fetch the front-end libraries, then second container would be just like the previous Dockerfile, but with one additional step -> copying the files from the first stage container
Something along the lines of:
FROM node:latest as builder
WORKDIR /code
COPY package* ./
RUN [“npm”, “install”]
FROM python:3.6.9-buster
RUN mkdir /code
WORKDIR /code
RUN apt-get update && apt-get install -y --allow-unauthenticated libsasl2-dev libssl-dev locales locales-all
ADD requirements* /code/
RUN pip install -r requirements.txt --default-timeout=180 -i https://pypi.lcsb.uni.lu/simple/ && pip install -r requirements-dev.txt --default-timeout=180 -i https://pypi.lcsb.uni.lu/simple/ # --use-feature=2020-resolver
ADD . /code/
COPY --from=builder /code/package_json /code/front-end-path/.../
RUN cp local_settings_ci.py smash/smash/local_settings.py
WORKDIR /code/smash
ENTRYPOINT [ "/bin/sh" ]
CMD [ "manage.py runserver 0.0.0.0:8888" ]
EXPOSE 8888