Skip to content

Commit 66eed0c

Browse files
author
iitzIrFan
committed
Enhance Docker setup: update .dockerignore, improve Dockerfile for clarity, and simplify docker-setup.md documentation
1 parent 9ac7e12 commit 66eed0c

4 files changed

Lines changed: 51 additions & 24 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
node_modules
2+
npm-debug.log
3+
Dockerfile
4+
docker-compose.yml
5+
.dockerignore
26
.git
7+
.gitignore
8+
logs
39
.DS_Store
410
build

Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
FROM node:20-alpine
1+
FROM node:20-alpine AS builder
22

33
WORKDIR /app
44

55
COPY package*.json ./
66

7+
# Install sharp dependencies
8+
RUN apk add --no-cache \
9+
g++ \
10+
make \
11+
python3 \
12+
libc6-compat
13+
14+
# Update npm to the latest version
15+
RUN npm install -g npm@latest
16+
717
RUN npm install --legacy-peer-deps
818

919
COPY . .
1020

11-
# No need to run 'npm run build' for development-mode Docker
21+
# Expose the application port
1222
EXPOSE 3000
1323

14-
CMD [ "npm", "run", "dev" ]
24+
# Start the application
25+
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- .:/app
99
- /app/node_modules # Prevents node_modules being overwritten by the mount
1010
working_dir: /app
11-
command: npm run dev -- --host 0.0.0.0 # THIS is the crucial change for hot-reload!
11+
command: npm run dev -- --host 0.0.0.0 # Ensure the server binds to 0.0.0.0
1212
environment:
1313
- NODE_ENV=development
1414
- CHOKIDAR_USEPOLLING=true

docker-setup.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,50 @@
1-
# Docker Container Setup - Documentation
1+
# Docker Container Setup - Simplified Documentation
22

3-
This is the documentation on how to containerize and run the recode hive website while using Docker.
3+
This guide explains how to set up and run the Recode Hive website using Docker.
44

5-
## Prerequesites
5+
## Prerequisites
66

7-
- [Docker](https://docs.docker.com/engine/install/) installed
8-
- Docker compose installed (Optional)
7+
- Install [Docker](https://docs.docker.com/engine/install/).
8+
- (Optional) Install Docker Compose for easier multi-container management.
99

1010
## Steps
1111

12-
### 1. Create a `Dockerfile` in the root directory
12+
### 1. Build and Run with Docker Compose (Recommended)
1313

14-
This is a text document that contains all the commands needs to build a Docker image. Basically a blue print of a docker image.
14+
Using Docker Compose simplifies the setup process. Run the following command in the project root directory:
1515

16-
Key instructions include <br>
16+
```bash
17+
docker-compose up --build
18+
```
19+
20+
This command will:
21+
- Build the Docker image.
22+
- Start the container.
23+
- Map port `3000` from the container to your local machine.
1724

18-
- `FROM <base_image>:<tag>` : The first instruction and specifies the base image to build upon.
19-
- `WORKDIR <path>` : Sets the working directory inside the container for subsequent instructions.
20-
- `COPY <source> <destination>` : This instruction copies files or directories from your local machine (the build context) into the Docker image.
21-
- `RUN <command>` : Executes commands during the image build process. This is used for installing dependencies, updating packages etc.
22-
- `EXPOSE <port>` : Informs docker that the container listens on the specified ports at runtime.
25+
Visit [http://localhost:3000](http://localhost:3000) to view the site.
2326

24-
### 2. Build the Docker Image
27+
### 2. Manual Setup with Docker (Optional)
2528

29+
If you prefer not to use Docker Compose, follow these steps:
30+
31+
#### a. Build the Docker Image
2632
```bash
2733
docker build -t recodehive-app .
2834
```
2935

30-
This command builds the Docker image using the instructions in the Dockerfile and tags it as recodehive-app.
31-
32-
### 3. Run the Container
33-
36+
#### b. Run the Docker Container
3437
```bash
3538
docker run -p 3000:3000 recodehive-app
3639
```
3740

38-
This runs the container and maps port 3000 from the container to your local machine. <br>
39-
Now Visit http://localhost:3000 to view the site.
41+
Visit [http://localhost:3000](http://localhost:3000) to view the site.
42+
43+
## Notes
44+
45+
- Ensure the `Dockerfile` and `docker-compose.yml` are correctly configured.
46+
- The application is set to bind to `0.0.0.0` for external access.
47+
- Use `docker logs <container_id>` to debug any issues.
48+
49+
For more details, refer to the official Docker documentation.
4050

0 commit comments

Comments
 (0)