Skip to content

Commit aac93fa

Browse files
committed
Add docker deployment
1 parent 2951c3a commit aac93fa

7 files changed

Lines changed: 2566 additions & 612 deletions

File tree

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
.git
4+
.gitignore
5+
.dockerignore
6+
Dockerfile
7+
README.md

.github/workflows/deploy.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Deploy Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Login to GitHub Container Registry
16+
uses: docker/login-action@v2
17+
with:
18+
registry: ghcr.io
19+
username: ${{ github.actor }}
20+
password: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Build and push
23+
uses: docker/build-push-action@v4
24+
with:
25+
context: .
26+
push: ${{ github.ref == 'refs/heads/main' }}
27+
tags: ghcr.io/${{ github.repository }}:latest

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Use Node.js LTS version
2+
FROM node:22-alpine
3+
4+
# Enable corepack and set Yarn version
5+
RUN corepack enable && corepack prepare yarn@4.4.0 --activate
6+
7+
# Set working directory
8+
WORKDIR /app
9+
10+
# Copy package files
11+
COPY package.json yarn.lock .yarnrc.yml ./
12+
13+
# Install dependencies
14+
RUN yarn install --immutable
15+
16+
# Copy source code
17+
COPY . .
18+
19+
# Build the application
20+
RUN yarn build
21+
22+
# Create non-root user for security
23+
RUN addgroup -g 1001 -S nodejs
24+
RUN adduser -S nestjs -u 1001
25+
26+
# Change ownership of the app directory
27+
RUN chown -R nestjs:nodejs /app
28+
USER nestjs
29+
30+
# Expose port (default NestJS port)
31+
EXPOSE 3001
32+
33+
# Start the application
34+
CMD ["node", "dist/main"]

bun.lock

Lines changed: 1682 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
api:
3+
build: .
4+
restart: unless-stopped
5+
ports:
6+
- '3001:3001'
7+
env_file:
8+
- .env

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"test:cov": "jest --coverage",
2020
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
2121
"test:e2e": "jest --config ./test/jest-e2e.json",
22-
"prepare": "husky"
22+
"prepare": "husky || true"
2323
},
2424
"dependencies": {
2525
"@nestjs/axios": "^3.1.3",
@@ -60,7 +60,6 @@
6060
"ts-jest": "29.2.5",
6161
"ts-loader": "^9.5.1",
6262
"ts-node": "^10.9.2",
63-
"tsconfig-paths": "4.2.0",
6463
"typescript": "^5.7.2"
6564
},
6665
"jest": {

0 commit comments

Comments
 (0)