Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.
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
18 changes: 0 additions & 18 deletions Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions docker-compose.yml

This file was deleted.

50 changes: 50 additions & 0 deletions docker/docker.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
#!/bin/sh
#####################################################################################
###
### Docker utilities
###
#####################################################################################

IMAGE_NAMES=(chapter_node chapter_app chapter_node_app chapter_client chapter_node_client)

CONTAINER_NAMES=(chapter_db_1 chapter_app_1 chapter_client_1)



REMOVE_ALL_IMAGES="remove_all_images"
REMOVE_ALL_CONTAINERS="remove_all_containers"

if [ "$#" -eq 0 ] || [ $1 = "-h" ] || [ $1 = "--help" ]; then
echo "Usage: ./du.sh [OPTIONS] COMMAND [arg...]"
echo " ./du.sh [ -h | --help ]"
echo ""
echo "Options:"
echo " -h, --help Prints usage."
echo ""
echo "Commands:"
echo " $REMOVE_ALL_IMAGES - Remove all images."
echo " $REMOVE_ALL_CONTAINERS - Remove all containers."
exit
fi

removeImages() {
docker rmi -f $(docker images -a -q)
docker images
}

removeContainers() {
docker stop $(docker ps -aq) && docker rm $(docker ps -aq)
docker ps -a
}

if [ $1 = $REMOVE_ALL_IMAGES ]; then
echo "Removing images ..."
removeImages
exit
fi

if [ $1 = $REMOVE_ALL_CONTAINERS ]; then
echo "Removing all containers ..."
removeContainers
exit
fi
17 changes: 17 additions & 0 deletions docker/models/demo/.env
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
# If running a local setup make sure to make IS_DOCKER unset
# IS_DOCKER=


# The folder this .env file is contained by expects the chapter directory to be 3 levels up
ROOT=../../..

DB_USER=postgres
DB_PASSWORD=password
DB_NAME=chapter
IS_DOCKER=true


CHAPTER_EMAIL=ourEmail@placeholder.place
EMAIL_USERNAME=emailUsernamePlaceholder
EMAIL_PASSWORD=emailPasswordPlaceholder
EMAIL_SERVICE=emailServicePlaceholder
10 changes: 10 additions & 0 deletions docker/models/demo/app/Dockerfile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
FROM demo_nodebase_app

WORKDIR /usr/chapter/

# Bundle app source
COPY . .

EXPOSE 5000

CMD [ "npm","run","dev" ]
10 changes: 2 additions & 8 deletions client/Dockerfile → docker/models/demo/client/Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
FROM node:13-alpine
FROM demo_nodebase_client

# Setting working directory. All the path will be relative to WORKDIR
WORKDIR /usr/chapter/client


# Installing dependencies
COPY package*.json ./
RUN npm install

# Copying source files
COPY . .
COPY ./client .

# Building app
RUN npm run build
Expand All@@ -18,4 +13,3 @@ EXPOSE 3000

# Running the app
CMD [ "npm", "run", "start" ]

50 changes: 50 additions & 0 deletions docker/models/demo/docker-compose.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
version: "3.7"
services:
db:
image: postgres:11
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME}
ports:
- "54320:5432"
adminer:
image: adminer
environment:
- ADMINER_DESIGN=mancave
restart: always
ports:
- 8080:8080
nodebase_app:
build:
context: ${ROOT}
dockerfile: ./docker/models/demo/node_app/Dockerfile
nodebase_client:
build:
context: ${ROOT}
dockerfile: ./docker/models/demo/node_client/Dockerfile
app:
depends_on:
- db
depends_on:
- nodebase_app
build:
context: ${ROOT}
dockerfile: ./docker/models/demo/app/Dockerfile
volumes:
- ./init.sh:/usr/chapter/init.sh
command: ./init.sh
environment:
- DB_URL=db
ports:
- 5000:5000
client:
depends_on:
- app
depends_on:
- nodebase_client
build:
context: ${ROOT}
dockerfile: ./docker/models/demo/client/Dockerfile
ports:
- 3000:3000
18 changes: 18 additions & 0 deletions docker/models/demo/init.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
#!/bin/sh
#####################################################################################
###
### Reset database
###
#####################################################################################



export DB_PORT=5432
export DB_USER=postgres
export DB_NAME=chapter
export DB_PASSWORD=password

echo ------------ Running App Init Script -------------
#sleep 20
yarn db:reset
yarn dev
10 changes: 10 additions & 0 deletions docker/models/demo/node_app/Dockerfile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
FROM node:14-alpine

# Setting working directory. All the path will be relative to WORKDIR
WORKDIR /usr/chapter

# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY ./package*.json ./

RUN npm install
10 changes: 10 additions & 0 deletions docker/models/demo/node_client/Dockerfile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
FROM node:14-alpine

# Setting working directory. All the path will be relative to WORKDIR
WORKDIR /usr/chapter/client

# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY ./client/package*.json ./

RUN npm install
27 changes: 27 additions & 0 deletions docker/models/demo/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
Notes:
################################################################################

Rough notes:

################################################################################


IMPORTANT!
If either of the package.json files change its dependencies, then the corresponding nodebase image needs to be rebuilt.


To run the demo:
cd chapter/docker/models/demo
docker-compose up

Environmental variables are stored in the .env file

Adminer

localhost:8080

System PostgreSQL
Server demo_db_1
Username postgres
Password password
Database chapter
6 changes: 3 additions & 3 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@
"morgan": "^1.9.1",
"next": "^9.5.1",
"nodemailer": "^6.3.1",
"pg": "^7.12.1",
"pg": "^8.0.3",
"pg-hstore": "^2.3.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
Expand All@@ -85,7 +85,7 @@
"@types/next": "^8.0.6",
"@types/node": "^13.7.1",
"@types/nodemailer": "^6.2.2",
"@types/pg": "^7.11.2",
"@types/pg": "^7.14.5",
"@types/react": "^16.9.9",
"@types/react-dom": "^16.9.2",
"@types/sinon-chai": "^3.2.3",
Expand DownExpand Up@@ -127,7 +127,7 @@
}
},
"engines": {
"node": "13.x",
"node": ">=13.x",
"npm": ">= 6.0.0"
}
}