Skip to content

CW2-6 Dockerise Website #6

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

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
Empty file added .env
Empty file.
8 changes: 8 additions & 0 deletions Dockerfiles/.dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD npm run dev
8 changes: 8 additions & 0 deletions Dockerfiles/.prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:16-alpine
RUN mkdir -p /app
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
## How to run locally
- Install dependencies with `npm install`
- Run using `npm run dev`

## How to run on docker
Download Docker Desktop from [here](https://www.docker.com/products/docker-desktop/).
Launch the Docker Desktop App.
Install the Docker extension on Visual Studio Code.

For a development environment run `docker-compose -f dev.docker-compose.yaml up`. This will reflect live code changes.
For a production environment run `docker-compose -f prod.docker-compose.yaml up`. This builds the environment way done for production.
13 changes: 13 additions & 0 deletions dev.docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.5'

services:
app:
build:
context: .
dockerfile: ./Dockerfiles/.dev.Dockerfile
container_name: docker-next
ports:
- '3000:3000'
volumes:
- .:/app
- /app/node_modules
13 changes: 13 additions & 0 deletions prod.docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.5'

services:
app:
build:
context: .
dockerfile: ./Dockerfiles/.prod.Dockerfile
container_name: docker-next
ports:
- '3000:3000'
volumes:
- .:/app
- /app/node_modules
Loading