-
Notifications
You must be signed in to change notification settings - Fork 121
Feature/docker optimization #929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sanjay-kv
merged 2 commits into
recodehive:main
from
iitzIrFan:feature/docker-optimization
Oct 14, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
FROM node:20-alpine | ||
FROM node:20-alpine AS builder | ||
|
||
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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 theAS builder
suffix to avoid confusion.Copilot uses AI. Check for mistakes.