|
1 |
| -# define base image |
2 |
| -FROM node:lts-slim |
| 1 | +FROM node:lts |
3 | 2 |
|
4 |
| -# download all the missing dependencies for chromium, plus chromium itself |
| 3 | +# Install missing dependencies for chromium |
| 4 | +# These are all needed to make sure the browser can properly render all |
| 5 | +# the requiredd page |
5 | 6 | RUN apt-get update && apt-get install -y \
|
6 | 7 | ca-certificates fonts-liberation gconf-service \
|
7 | 8 | libappindicator1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 \
|
8 | 9 | libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 \
|
9 | 10 | libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 \
|
10 | 11 | libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
|
11 | 12 | libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \
|
12 |
| - libxss1 libxtst6 lsb-release libxshmfence1 chromium -y |
| 13 | + libxss1 libxtst6 lsb-release libxshmfence1 chromium -y \ |
| 14 | + && rm -rf /var/lib/apt/lists/* |
13 | 15 |
|
14 |
| -# ENV NODE_ENV=production |
15 |
| -ENV YARN_VERSION 1.22.17 |
16 |
| -#ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD 1 |
17 |
| -RUN yarn policies set-version $YARN_VERSION |
18 |
| -#ENV CHROME_BIN /usr/bin/chromium |
19 |
| -#ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium |
20 |
| - |
21 |
| -# define working directory inside the container |
| 16 | +# Set working directory |
22 | 17 | WORKDIR /usr/src/app
|
23 | 18 |
|
24 |
| -# Copy all the source code from host machine to the container project directory |
| 19 | +# Copy source code |
25 | 20 | COPY . .
|
26 | 21 |
|
27 |
| -# install all the dependencies |
28 |
| -RUN yarn --frozen-lockfile && yarn build |
| 22 | +# Install dependencies |
| 23 | +RUN npm install && \ |
| 24 | + NODE_ENV=production npm run build && \ |
| 25 | + npm install --omit=dev |
29 | 26 |
|
30 |
| -# yarn build creates the bin/ folder |
| 27 | +# Copy environment file to bin folder |
31 | 28 | COPY .env bin/
|
32 | 29 |
|
33 |
| -# change directory to the bin diretory |
| 30 | +# Change directory to bin |
34 | 31 | WORKDIR /usr/src/app/bin/
|
35 | 32 |
|
36 |
| -# make sure the node user is the owner of all the underlying files. |
| 33 | +# Set ownership |
37 | 34 | RUN chown -R node:node *
|
38 | 35 |
|
39 |
| -# ensure this container runs as the user "node" |
| 36 | +# Switch to non-root user |
40 | 37 | USER node
|
41 | 38 |
|
42 |
| -# define the start up command of the container to run the server |
43 |
| -CMD ["node", "server/app.js"] |
| 39 | +# Define startup command |
| 40 | +CMD ["NODE_ENV=production", "node", "server/app.js"] |
| 41 | + |
0 commit comments