Skip to content

Commit 25eaa62

Browse files
authored
Merge pull request #193 from upayanmazumder/staging
Docker!
2 parents 0c56e46 + 9b76579 commit 25eaa62

File tree

4 files changed

+85
-11
lines changed

4 files changed

+85
-11
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
npm-debug.log
3+
.DS_Store
4+
.git
5+
.gitignore
6+
.env

Dockerfile

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,58 @@
1-
# Step 1: Specify the base image
2-
FROM node:22
1+
# Step 1: Build stage
2+
FROM node:23-alpine AS builder
33

4-
# Step 2: Set the working directory inside the container
4+
# Install dependencies required for building native modules
5+
RUN apk add --no-cache \
6+
python3 \
7+
make \
8+
g++ \
9+
pkgconfig \
10+
pixman-dev \
11+
cairo-dev \
12+
pango-dev \
13+
glib-dev \
14+
jpeg-dev \
15+
giflib-dev
16+
17+
# Install pnpm globally
18+
RUN npm install -g pnpm
19+
20+
# Set the working directory
521
WORKDIR /app
622

7-
# Step 3: Copy package.json and package-lock.json files
8-
COPY package*.json ./
23+
# Copy package.json and pnpm-lock.yaml
24+
COPY package.json pnpm-lock.yaml ./
925

10-
# Step 4: Install dependencies
11-
RUN npm install
26+
# Install dependencies using pnpm
27+
RUN pnpm install --frozen-lockfile
1228

13-
# Step 5: Copy the rest of the application code
29+
# Copy the rest of the application code
1430
COPY . .
1531

16-
# Step 6: Expose the port the application runs on
32+
# Build the application
33+
RUN pnpm run build
34+
35+
# Step 2: Production stage
36+
FROM node:23-alpine
37+
38+
# Install pnpm globally
39+
RUN npm install -g pnpm
40+
41+
# Set the working directory
42+
WORKDIR /app
43+
44+
# Set NODE_ENV to production
45+
ENV NODE_ENV=production
46+
47+
# Copy only the built application and necessary files from the builder stage
48+
COPY --from=builder /app/package.json ./
49+
COPY --from=builder /app/pnpm-lock.yaml ./
50+
COPY --from=builder /app/node_modules ./node_modules
51+
COPY --from=builder /app/.next ./.next
52+
COPY --from=builder /app/public ./public
53+
54+
# Expose the port the application runs on
1755
EXPOSE 3000
1856

19-
# Step 7: Define the command to run the application
20-
CMD ["npm","run","dev"]
57+
# Define the command to start the application
58+
CMD ["pnpm", "start"]

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
> <p>Prepare to excel in your CATs and FATs with CodeChef-VIT's dedicated repository of past exam papers. Access key resources to review concepts, tackle challenging questions, and familiarize yourself with exam patterns. Boost your confidence, sharpen your strategy, and get ready to ace your exams!</p>
88
99
## 🌐 Deploy
10+
1011
[https://papers.codechefvit.com](https://papers.codechefvit.com/)
1112

1213
## ⚙️ Tech Stack:
@@ -62,6 +63,28 @@ To start your development server run:
6263
pnpm dev
6364
```
6465

66+
## 🐳 Using Docker
67+
68+
To run the application using Docker, follow these steps:
69+
70+
1. **Build the Docker Image**:
71+
72+
```bash
73+
docker build -t papers-codechef .
74+
```
75+
76+
2. **Run the Docker Container**:
77+
78+
```bash
79+
docker run -p 3000:3000 --env-file .env papers-codechef
80+
```
81+
82+
3. **Using Docker Compose**:
83+
If you prefer `docker-compose`, ensure the `docker-compose.yml` file is configured, then run:
84+
```bash
85+
docker-compose up
86+
```
87+
6588
Before getting started, please ensure that the .env file is properly configured. The .env.example file has been provided for your reference, with examples of environment variables to be listed.
6689

6790
## License

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
app:
3+
build: .
4+
ports:
5+
- "3000:3000"
6+
env_file:
7+
- .env.local

0 commit comments

Comments
 (0)