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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.git
.DS_Store
build
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18-alpine AS builder

# Set working directory inside the container
WORKDIR /app

COPY package*.json ./

# Install dependencies with legacy peer deps fix
RUN npm install --legacy-peer-deps

COPY . .
RUN npm run build

# Production Image
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app /app
EXPOSE 3000

CMD ["npm", "run","serve"]
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.9"

services:
recodehive:
build:
context: .
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
working_dir: /app
command: npm run start
environment:
- NODE_ENV=development
30 changes: 30 additions & 0 deletions docker-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docker Container Setup - Documentation

This is the documentation on how to containerize and run the Recodehive website while using Docker.

## Prerequesites
- [Docker](https://docs.docker.com/engine/install/) installed
- Docker compose installed (Optional)

## Steps
### 1. Create a `Dockerfile` in the root directory
This is a text document that contains all the commands needs to build a Docker image. Basically a blue print of a docker image.

Key instructions include <br>
- `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. Build the Docker Image
```bash
docker build -t recodehive-app .
```
This command builds the Docker image using the instructions in the Dockerfile and tags it as recodehive-app.
### 3. Run the Container
```bash
docker run -p 3000:3000 recodehive-app
```
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.
Loading