ARG DEVELOPMENT= # # Base Ubuntu image with nodejs installed # FROM ubuntu:jammy AS base RUN apt-get update \ && DEBIAN_FRONTEND=NONINTERACTIVE apt-get upgrade -y RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \ wget # Upgrade Node RUN wget -qO- https://deb.nodesource.com/setup_18.x | bash - RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \ nodejs # Install the latest npm and npx RUN npm install --global npm@latest # # 'production' is used as a COPY source when building # PRODUCTION mode (via website image) # FROM base AS production RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \ git # Polymer frontend app built using bower WORKDIR /website/frontend COPY /frontend /website/frontend RUN npx -y bower --allow-root -y install # Not sure if the root is actually used for anything... # It does have dependencies on frontend WORKDIR /website COPY /package.json /website/ RUN npm install COPY /.babelrc /*.html /*.js /website/ COPY /src /website/src COPY /.env /website/ RUN npm run build # 'identities' frontend built using react WORKDIR /website/client COPY /client/package.json /website/client/ RUN npm install COPY /client/tsconfig.json /website/client/ COPY /client/*.js /website/client/ COPY /client/public /website/client/public COPY /client/src /website/client/src COPY /client/.env /website/client/ RUN npm run build # # 'runtime' is the bulk of the DeepFace infrastructure # FROM base AS runtime RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \ pip \ libgl1 \ libglib2.0-0 \ nginx \ rsync \ git \ sqlite3 \ python2 \ jhead \ jq \ nano \ shellinabox \ curl \ less # Install deepface RUN pip install deepface RUN pip install piexif # numpy 1.24 deprecated float; deepface is still using it, so we need to # install <1.24 RUN pip install "numpy<1.24" WORKDIR /website/server COPY /server/package.json /website/server/ RUN npm install COPY /.env /website/ COPY /config /website/config COPY /server/*.js /website/server/ COPY /server/db /website/server/db COPY /server/routes /website/server/routes COPY /server/lib /website/server/lib # Copy the Python face management scripts COPY /ketrface /website/ketrface # # 'website' is used if DEVELOPMENT is not set (PRODUCTION) # FROM runtime AS website RUN echo "Building PRODUCTION" COPY /server/production.location /etc/nginx/snippets/active.location COPY --from=production /website/frontend /website/frontend COPY --from=production /website/dist /website/dist COPY --from=production /website/*.html /website/ COPY --from=production /website/client/build /website/client/build # # 'website1' is used if DEVELOPMENT=1 # FROM runtime AS website1 RUN echo "Building DEVELOPMENT" COPY /server/development.location /etc/nginx/snippets/active.location COPY /package.json /website/ # # This is the final image stage pulling together 'runtime' and the # appropriate website build (website or website1) # FROM website${DEVELOPMENT} AS final COPY /config/default.json /website/config/default.json # Switch to bash instead of sh SHELL [ "/bin/bash", "-c" ] COPY /server/nginx.conf /etc/nginx/sites-enabled/default COPY /scripts /opt/scripts ENV PATH="${PATH}:/opt/scripts" # In DEVELOPMENT mode, entrypoint launches 'npm start' COPY /entrypoint.sh / CMD [ "/entrypoint.sh" ]