diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..848f60b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +dist +storage diff --git a/docker-compose.yml b/docker-compose.yml index 8da8cb1..ab69cf8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,13 @@ -version: '2' - services: - app: - build: docker/app + build: + dockerfile: docker/app/Dockerfile + init: true restart: unless-stopped - volumes: - - ./:/app nginx: image: nginx restart: unless-stopped volumes: - ./docker/nginx/conf.d:/etc/nginx/conf.d:ro - - ./logs:/logs - ./dist:/usr/share/nginx/html:ro diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index 0bbeabc..203cfa9 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -1,22 +1,27 @@ -FROM node:12 +FROM node:20 -# Chrome/Puppeteer support +# Puppeteer support +# Adapted from: https://github.com/puppeteer/puppeteer/blob/2d50ec5b384f2ae8eb02a534843caceca9f58ffe/docker/Dockerfile RUN apt-get update \ && apt-get install -y wget gnupg \ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ && apt-get update \ - && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \ + && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 \ --no-install-recommends \ && rm -rf /var/lib/apt/lists/* -# Install dumb-init -# https://github.com/Yelp/dumb-init -# This fixes issues with zombie Chrome processes: -# https://github.com/GoogleChrome/puppeteer/issues/615 -RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb &&\ - dpkg -i dumb-init_*.deb - +# App setup WORKDIR /app -ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["yarn", "cron"] +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true + +# Install NPM dependencies +COPY package*.json ./ +RUN npm install + +# Copy app files and build +COPY . . +RUN npm run build + +CMD ["npm", "run", "start"] +