Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
node_modules
npm-debug.log
Dockerfile
docker-compose.yml
.dockerignore
.git
.gitignore
logs
.DS_Store
build
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
FROM node:20-alpine
FROM node:20-alpine AS builder
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dockerfile uses a multi-stage build syntax (AS builder) but doesn't utilize multiple stages. Either implement a proper multi-stage build or remove the AS builder suffix to avoid confusion.

Suggested change
FROM node:20-alpine AS builder
FROM node:20-alpine

Copilot uses AI. Check for mistakes.


WORKDIR /app

COPY package*.json ./

# Install sharp dependencies
RUN apk add --no-cache \
g++ \
make \
python3 \
libc6-compat

# Update npm to the latest version
RUN npm install -g npm@latest

RUN npm install --legacy-peer-deps

COPY . .

# No need to run 'npm run build' for development-mode Docker
# Expose the application port
EXPOSE 3000

CMD [ "npm", "run", "dev" ]
# Start the application
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- .:/app
- /app/node_modules # Prevents node_modules being overwritten by the mount
working_dir: /app
command: npm run dev -- --host 0.0.0.0 # THIS is the crucial change for hot-reload!
command: npm run dev -- --host 0.0.0.0 # Ensure the server binds to 0.0.0.0
environment:
- NODE_ENV=development
- CHOKIDAR_USEPOLLING=true
61 changes: 39 additions & 22 deletions docker-setup.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,57 @@
# Docker Container Setup - Documentation
# Docker Container Setup - Beginner-Friendly Guide

This is the documentation on how to containerize and run the recode hive website while using Docker.
This guide explains how to set up and run the Recode Hive website using Docker in the simplest way possible.

## Prerequesites
## Prerequisites

- [Docker](https://docs.docker.com/engine/install/) installed
- Docker compose installed (Optional)
- Install [Docker](https://docs.docker.com/engine/install/).
- Install Docker Compose (usually included with Docker Desktop).

## Steps

### 1. Create a `Dockerfile` in the root directory
### 1. Start the Application with Docker Compose

This is a text document that contains all the commands needs to build a Docker image. Basically a blue print of a docker image.
The easiest way to run the application is by using Docker Compose. Simply run the following command in the project root directory:

Key instructions include <br>
```bash
docker-compose up --build
```

This command will:
- Build the Docker image.
- Start the container.
- Map port `3000` from the container to your local machine.

Once the setup is complete, visit [http://localhost:3000](http://localhost:3000) to view the site.

- `FROM <base_image>:<tag>` : The first instruction and specifies the base image to build upon.
- `WORKDIR <path>` : Sets the working directory inside the container for subsequent instructions.
- `COPY <source> <destination>` : This instruction copies files or directories from your local machine (the build context) into the Docker image.
- `RUN <command>` : Executes commands during the image build process. This is used for installing dependencies, updating packages etc.
- `EXPOSE <port>` : Informs docker that the container listens on the specified ports at runtime.
### 2. Stop the Application

### 2. Build the Docker Image
To stop the application, press `Ctrl+C` in the terminal where the application is running. Then, remove the containers with:

```bash
docker build -t recodehive-app .
docker-compose down
```

This command builds the Docker image using the instructions in the Dockerfile and tags it as recodehive-app.
### 3. Debugging Tips

### 3. Run the Container
- **View Logs:** If you encounter issues, check the container logs:
```bash
docker-compose logs
```
- **Rebuild the Image:** If you make changes to the code, rebuild the image:
```bash
docker-compose up --build
```
- **Access the Container Shell:** To debug inside the container:
```bash
docker exec -it <container_name> sh
```

```bash
docker run -p 3000:3000 recodehive-app
```
### Notes

- The `docker-compose.yml` file is pre-configured for development.
- The application is set to bind to `0.0.0.0` for external access.
- File changes on your local machine will automatically reflect in the container (hot-reloading enabled).

This runs the container and maps port 3000 from the container to your local machine. <br>
Now Visit http://localhost:3000 to view the site.
For more details, refer to the official Docker documentation.

Loading