Skip to content

Commit

Permalink
Refactor Dockerfile sso
Browse files Browse the repository at this point in the history
Update playwright to 1.20.2
  • Loading branch information
Kevan-Y committed Apr 11, 2022
1 parent 009ce52 commit 28dff96
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"jest-runner": "27.5.1",
"nock": "13.2.4",
"npm-run-all": "4.1.5",
"playwright": "1.19.2",
"playwright": "1.20.2",
"prettier": "2.5.1",
"pretty-quick": "3.1.3",
"redis-commands": "1.7.0",
Expand Down
32 changes: 22 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/api/sso/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ npm-debug.log
Dockerfile
.git
.gitignore
jest*
.env*
test/
40 changes: 19 additions & 21 deletions src/api/sso/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Base ########################################################################
## Base ###########################################################################
# Set up the base layer
# Use a larger node image to do the build for native deps (e.g., gcc, pytyhon)
FROM node:lts as base

Expand All @@ -11,36 +12,33 @@ WORKDIR /home/node/app
# Copy the package.json and lock file over
COPY package*.json /home/node/app/

## Development #################################################################
# Define a development target that installs devDeps and runs in dev mode
FROM base as development
WORKDIR /home/node/app
# Install (not ci) with dependencies, and for Linux vs. Linux Musl (which we use for -alpine)
RUN npm install
# Copy the source code over
COPY --chown=node:node . /home/node/app/
# Switch to the node user vs. root
USER node
# Start the app in debug mode so we can attach the debugger
CMD ["npm", "run", "dev"]
## Dependencies ###################################################################
# Stage for installing prod dependencies
FROM base as dependencies

## Production ##################################################################
# Also define a production target which doesn't use devDeps
FROM base as production
WORKDIR /home/node/app
# We'll install production only deps
RUN npm install --production

## Deploy ######################################################################
# Stage for that run our app
# Use a smaller node image (-alpine) at runtime
FROM node:lts-alpine as deploy

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/

# Copy prodduction node_modules from dependencies
COPY --chown=node:node --from=dependencies /home/node/app/node_modules ./node_modules/

# Copy the source code
COPY --chown=node:node . /home/node/app/
COPY --chown=node:node . .

# Switch to the node user vs. root
USER node

ENV SSO_PORT=7777

# Docker Healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider localhost:${SSO_PORT}/healthcheck || exit 1

# Start the app
CMD ["node", "src/server.js"]

0 comments on commit 28dff96

Please sign in to comment.