diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..5806c1e --- /dev/null +++ b/dockerfile @@ -0,0 +1,97 @@ +# = Do.Doc Docker = + +# ==================================================== # +# == Base for build == +# ==================================================== # +FROM node:12.18.3 AS build-base +RUN apt-get update && apt-get install -y python2.7 git ca-certificates wget file fftw-dev sudo && \ + update-ca-certificates +#RUN apk --update --no-cache add python2 build-base git ca-certificates wget file fftw-dev sudo && \ +# update-ca-certificates + +# Install global dependencies +RUN npm i extract-zip +RUN sudo npm install -g node-gyp --unsafe-perm=true --allow-root --save-dev --save-exact +RUN npm i ajv + +# Ready to start do.doc specific dependencies + +# ==================================================== # +# == server == +# ==================================================== # +FROM build-base AS build-server + +# node-canvas missing for alpine, must compile from source +# https://github.com/Automattic/node-canvas/issues/1486 +#RUN apk add --update --no-cache \ +# make \ + # g++ \ + # jpeg-dev \ + # cairo-dev \ + # giflib-dev \ + # pango-dev \ + # && npm i canvas --build-from-source + +# Install server dependencies +WORKDIR /src/l-atelier-des-chercheurs/dodoc +COPY package*.json ./ +RUN npm install --unsafe-perm=true +COPY . /src/l-atelier-des-chercheurs/dodoc/ +#RUN npm build --unsafe-perm=true + +# ==================================================== # +# == Client == +# ==================================================== # +FROM build-base AS build-client +# Install client dependencies +WORKDIR /src/l-atelier-des-chercheurs/dodoc/public/ +COPY public/package*.json ./ +RUN npm install --unsafe-perm=true +COPY public /src/l-atelier-des-chercheurs/dodoc/public +#RUN npm run dev --unsafe-perm=true && npm run build --unsafe-perm=true +RUN npm run build --unsafe-perm=true + + + +# ==================================================== # +# == Serving == +# ==================================================== # +FROM node:12.18.3 + +RUN apt-get update && apt-get install -y curl libx11-xcb1 libxcomposite1 libxi6 libxext6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libasound2 libpangocairo-1.0-0 libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0 +# RUN apk add --update --no-cache curl libx11 libxcomposite libxi libxext libxtst nss cups-libs libxscrnsaver libxrandr alsa-lib pango atk at-spi2-atk gtk+3.0 +# RUN apk add --update --no-cache giflib-dev +# RUN apk update && apk upgrade +# RUN apk add --update --no-cache harfbuzz freetype ttf-freefont +# RUN apk add --update --no-cache chromium + + + +# Tell Puppeteer to skip installing Chrome. We'll be using the installed package. +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true +# RUN yarn add puppeteer + +# Add user so we don't need --no-sandbox. +# RUN addgroup -S node && adduser -S -g node node \ +RUN mkdir -p /home/node/Downloads \ + && chown -R node:node /home/node +# && chown -R node:node /application + +EXPOSE 8080 + +WORKDIR /src/l-atelier-des-chercheurs/dodoc + +COPY . . +COPY --from=build-server /src/l-atelier-des-chercheurs/dodoc/node_modules node_modules +COPY --from=build-client /src/l-atelier-des-chercheurs/dodoc/public/dist/ /src/l-atelier-des-chercheurs/dodoc/public/dist/ +COPY --from=build-base /usr/local/lib/node_modules /usr/local/lib/node_modules + +HEALTHCHECK --interval=5s \ + --timeout=5s \ + --retries=6 \ + CMD curl -fs http://localhost:8080/ || exit 1 + + + +USER node +CMD npm run debug \ No newline at end of file