Skip to content

Commit

Permalink
chore: Update Dockerfile and add GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sujal-goswami committed Aug 12, 2024
1 parent 7b00a7d commit fbd879f
Show file tree
Hide file tree
Showing 3 changed files with 393 additions and 234 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build --if-present

- name: Run tests
run: npm run test
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# Stage 0: base image
# Stage 1: base image
FROM node:lts-alpine AS base
WORKDIR /app
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install

# Stage 1: Development environment
# Stage 2: Development environment
FROM base AS development
ENV NODE_ENV=development
COPY . .
EXPOSE 8000
RUN chown -R node /app
USER node
CMD ["npm", "run", "dev"]

# Stage 2: Production environment
# Stage 3: Production environment
FROM base AS production
ENV NODE_ENV=production
COPY . .
RUN rm -rf tests
RUN npm prune --production
EXPOSE 8000
RUN chown -R node /app
Expand Down
Loading

0 comments on commit fbd879f

Please sign in to comment.