Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check PR

on:
pull_request:
branches: [ $default-branch ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: npm ci
- name: Run ESLint
run: npm run lint

tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]

steps:
- uses: actions/checkout@v2
- name: Test with node-${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
29 changes: 14 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:12.14.0-alpine3.11
FROM node:12.14.0-alpine3.11 as builder
WORKDIR /sources
COPY . .
RUN npm ci --only=prod
# Clean node_modules
RUN npx modclean --no-progress --run

# Set NODE_ENV to prevent installation of dev dependencies in production
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}

FROM node:12.14.0-alpine3.11

# Set to a non-root built-in user `node`
USER node

# Create app directory (with user `node`)
RUN mkdir -p /home/node/app

WORKDIR /home/node/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=node package*.json ./
COPY --from=builder --chown=node /sources/node_modules ./node_modules
COPY --from=builder --chown=node /sources/package.json ./package.json
COPY --from=builder --chown=node /sources/src ./src

RUN npm install
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

# Bundle app source code
COPY --chown=node . .
EXPOSE 8000

CMD [ "npm", "run", "start:prod" ]
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
db:
image: postgres:12.1
image: postgres:12.5-alpine
ports:
- 8432:5432
volumes:
Expand All @@ -13,6 +13,9 @@ services:
- "8000:8000"
env_file:
- .env
volumes:
- .env:/home/node/app/.env
- .env.example:/home/node/app/.env.example
depends_on:
- db
command: npm start
Expand Down
Loading