Skip to content

Commit 68d89a8

Browse files
committed
added docker
1 parent fc5ea3d commit 68d89a8

4 files changed

Lines changed: 54 additions & 0 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
.next
3+
.git
4+
.gitignore
5+
README.md
6+
coverage
7+
.env
8+
.env.*

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ jobs:
3636
- name: Test
3737
run: npm test
3838

39+
- name: Build Docker Image
40+
run: docker build -t playwithalgorithms .
41+
3942
- name: Build
4043
run: npm run build

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Build stage (builder)
2+
FROM node:22-alpine AS builder
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package files first (for caching)
8+
COPY package*.json ./
9+
10+
# Install all dependencies
11+
RUN npm ci
12+
13+
# Copy rest of the code
14+
COPY . .
15+
16+
# Build Next.js app
17+
RUN npm run build
18+
19+
# Runtime stage
20+
FROM node:22-alpine AS runner
21+
22+
WORKDIR /app
23+
24+
# Copy only required files from builder
25+
COPY --from=builder /app/package*.json ./
26+
COPY --from=builder /app/node_modules ./node_modules
27+
COPY --from=builder /app/.next ./.next
28+
COPY --from=builder /app/public ./public
29+
30+
# Expose app port
31+
EXPOSE 3000
32+
33+
# Start app
34+
CMD ["npm", "run", "start"]

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: "3.9"
2+
3+
services:
4+
app:
5+
image: playwithalgorithms
6+
container_name: playwithalgorithms
7+
ports:
8+
- "3000:3000"
9+

0 commit comments

Comments
 (0)