Skip to content

Commit 35e8685

Browse files
committed
feat: Dockerize recodehive
1 parent bb880b4 commit 35e8685

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.git
3+
.DS_Store
4+
build

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM node:18-alpine AS builder
2+
3+
# Set working directory inside the container
4+
WORKDIR /app
5+
6+
COPY package*.json ./
7+
8+
# Install dependencies with legacy peer deps fix
9+
RUN npm install --legacy-peer-deps
10+
11+
COPY . .
12+
RUN npm run build
13+
14+
# Production Image
15+
FROM node:18-alpine
16+
WORKDIR /app
17+
COPY --from=builder /app /app
18+
EXPOSE 3000
19+
20+
CMD ["npm", "run","serve"]

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3.9"
2+
3+
services:
4+
recodehive:
5+
build:
6+
context: .
7+
ports:
8+
- "3000:3000"
9+
volumes:
10+
- .:/app
11+
- /app/node_modules
12+
working_dir: /app
13+
command: npm run start
14+
environment:
15+
- NODE_ENV=development

docker-setup.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Docker Container Setup - Documentation
2+
3+
This is the documentation on how to containerize and run the Recodehive website while using Docker.
4+
5+
## Prerequesites
6+
- [Docker](https://docs.docker.com/engine/install/) installed
7+
- Docker compose installed (Optional)
8+
9+
## Steps
10+
### 1. Create a `Dockerfile` in the root directory
11+
This is a text document that contains all the commands needs to build a Docker image. Basically a blue print of a docker image.
12+
13+
Key instructions include <br>
14+
- `FROM <base_image>:<tag>` : The first instruction and specifies the base image to build upon.
15+
- `WORKDIR <path>` : Sets the working directory inside the container for subsequent instructions.
16+
- `COPY <source> <destination>` : This instruction copies files or directories from your local machine (the build context) into the Docker image.
17+
- `RUN <command>` : Executes commands during the image build process. This is used for installing dependencies, updating packages etc.
18+
- `EXPOSE <port>` : Informs docker that the container listens on the specified ports at runtime.
19+
20+
### 2. Build the Docker Image
21+
```bash
22+
docker build -t recodehive-app .
23+
```
24+
This command builds the Docker image using the instructions in the Dockerfile and tags it as recodehive-app.
25+
### 3. Run the Container
26+
```bash
27+
docker run -p 3000:3000 recodehive-app
28+
```
29+
This runs the container and maps port 3000 from the container to your local machine. <br>
30+
Now Visit http://localhost:3000 to view the site.

0 commit comments

Comments
 (0)