Skip to content

Commit

Permalink
update Dockerfile for Docusaurus to use tini
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyorangis committed Feb 3, 2022
1 parent 9fa4819 commit 6da79bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 7 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ module.exports = {
],
plugins: ['react', 'react-hooks'],
rules: {
// https://github.com/facebook/docusaurus/blob/main/.eslintrc.js#L122
// Ignore certain webpack aliases because they can't be resolved
'import/no-unresolved': [
'off',
'error',
{
ignore: ['^@theme', '^@docusaurus', '^@generated', '^@site'],
},
Expand All @@ -112,20 +114,19 @@ module.exports = {
'no-use-before-define': 'off',
'node/no-missing-import': 'off',
'node/no-unsupported-features/es-syntax': 'off',
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'react/jsx-filename-extension': ['off', { extensions: ['.js', '.jsx'] }],
// https://github.com/facebook/docusaurus/blob/main/.eslintrc.js#L154
// We build a static site, and nearly all components don't change.
'react/no-array-index-key': 'off',
'react/prop-types': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
moduleDirectory: ['src/docs/node_modules', 'src/docs/'],
moduleDirectory: ['src/docs/node_modules', 'src/docs/src'],
},
},
react: {
version: '17.0',
},
},
},
],
Expand Down
13 changes: 5 additions & 8 deletions src/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ CMD ["npm", "run", "start"]
# Also define a production target which doesn't use devDeps
FROM base as production
WORKDIR /home/node/app
# We'll install production only deps, and target the Linux Musl x64 for alpine.
RUN npm install --platform=linuxmusl --arch=x64 --production
# We'll install production only deps
RUN npm install --production

## Deploy ######################################################################
# Use a smaller node image (-alpine) at runtime
FROM node:lts-alpine as deploy
# Install dumb-init, see:
# https://snyk.io/blog/10-best-practices-to-containerize-nodejs-web-applications-with-docker/
# Install specific version, and don't cache https://github.com/hadolint/hadolint/wiki/DL3018
# https://pkgs.alpinelinux.org/package/edge/community/x86/dumb-init
RUN apk --no-cache add dumb-init=1.2.5-r1
# https://github.com/krallin/tini
RUN apk --no-cache add tini
WORKDIR /home/node/app
# Copy what we've installed/built from production
COPY --chown=node:node --from=production /home/node/app/node_modules /home/node/app/node_modules/
Expand All @@ -49,4 +46,4 @@ COPY --chown=node:node . /home/node/app/
# Switch to the node user vs. root
USER node
# Start the app
CMD ["dumb-init", "npm", "run", "build"]
CMD ["tini", "npm", "run", "build"]

0 comments on commit 6da79bc

Please sign in to comment.