ketr.photos/Dockerfile
2023-01-19 19:00:59 -08:00

102 lines
2.3 KiB
Docker

ARG DEVELOPMENT=
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 -
# Install the latest npm and npx
RUN npm install --global npm@latest
FROM base AS production
WORKDIR /website
COPY /*.html /*.js /*.json /website/
RUN npm install && npm run build
WORKDIR /website/client
RUN mv ../node_modules .
COPY /client/*.js /client/*.json /client/public /client/src /website/client/
RUN npm install && npm run build
FROM production AS runtime1
ONBUILD COPY --from=production /website/dist /website/dist
ONBUILD COPY --from=production /website/*.html /website/
ONBUILD COPY --from=production /website/client/*.html /website/client/
ONBUILD COPY --from=production /website/client/dist/ /website/client/dist/
FROM base AS runtime
FROM runtime${DEVELOPMENT}
RUN DEBIAN_FRONTEND=NONINTERACTIVE apt-get install -y \
pip \
libgl1 \
libglib2.0-0 \
nginx \
rsync \
less \
git \
sqlite3 \
python2 \
jhead \
nodejs \
jq \
nano \
shellinabox \
nginx \
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"
COPY /server /website/server
WORKDIR /website/server
RUN npm install
COPY /config/default.json /website/config/default.json
COPY /ketrface /website/ketrface
# Switch to bash instead of sh
SHELL [ "/bin/bash", "-c" ]
RUN cp /website/server/nginx.conf /etc/nginx/sites-enabled/default
# If not DEVELOPMENT mode, copy production config, else development
RUN \
if [[ -z "${DEVELOPMENT}" ]]; then \
echo "Building PRODUCTION" ; \
cp /website/server/production.location \
/etc/nginx/snippets/active.location ; \
else \
echo "Building DEVELOPMENT" ; \
cp /website/server/development.location \
/etc/nginx/snippets/active.location ; \
fi
# If not DEVELOPMENT mode, then locally build project
RUN \
if [[ -z "${DEVELOPMENT}" ]]; then \
cd /website/client ; \
npm run build ; \
fi
COPY /scripts /opt/scripts
ENV PATH="${PATH}:/opt/scripts"
# In DEVELOPMENT mode, entrypoint launches 'npm start'
COPY /entrypoint.sh /
CMD [ "/entrypoint.sh" ]