- Install Docker Desktop: https://www.docker.com/products/docker-desktop
After cloning the repo follow these steps.
- Edit Hosts file:
sudo vim /etc/hosts
- Add this to the end of your
/etc/hosts
file:
127.0.0.1 alison.test
127.0.0.1 db-api.alison.test
127.0.0.1 db-etl.alison.test
127.0.0.1 web-app.alison.test
127.0.0.1 web-cms.alison.test
127.0.0.1 web-etl.alison.test
127.0.0.1 server-api.alison.test
127.0.0.1 server-etl.alison.test
127.0.0.1 server-gql.alison.test
127.0.0.1 server-strapi.alison.test
- Type
ESC:wq
to save and quit vim. - In a Terminal window
cd
to the directory with thedocker-compose.yml
file. - Run the
docker-compose
command to build the images and start the containers. The strapi container takes a few minutes to start for the first time.
docker-compose up
-
Once all the docker containers have started try visiting:
-
Connect to MySQL Containers If desired:
db-api (used by strapi)
host: alison.test
port: 4400
username: api
password: api
database: api
db-etl (example db running in parallel)
host: alison.test
port: 4401
username: etl
password: etl
database: etl
- Stop the containers
docker-compose stop
- When making container or image changes you can run this command to rebuild and start.
docker-compose --force-recreate --always-recreate-deps --build
Build based on docker-compose file and don't use cached images.
docker-compose build --no-cache
Start and make sure everything is blown away and recreated from the ground up.
docker-compose up --force-recreate --always-recreate-deps --build
Create a named network dns hostnames to be resolved.
docker network create alison-net
cd ./server-api
Build the Image from the Dockerfile:
docker build . \
--no-cache \
--label server-api \
--tag trozdol/server-api
Run the container based on the above image:
docker run \
--rm \
--detach \
--env NODE_ENV=dev \
--env PORT=80 \
--publish 8000:80 \
--network alison-net \
--name server-api \
--hostname server-api \
trozdol/server-api
cd ./server-etl
Build the Image from the Dockerfile:
docker build . \
--no-cache \
--label server-etl \
--tag trozdol/server-etl
Run the container based on the above image:
docker run \
--rm \
--detach \
--env NODE_ENV=dev \
--env PORT=80 \
--publish 8001:80 \
--network alison-net \
--name server-etl \
--hostname server-etl \
trozdol/server-etl
cd ./server-gql
Build the Image from the Dockerfile:
docker build . \
--no-cache \
--label server-gql \
--tag trozdol/server-gql
Run the container based on the above image:
docker run \
--rm \
--detach \
--env NODE_ENV=dev \
--env PORT=80 \
--publish 8002:80 \
--network alison-net \
--name server-gql \
--hostname server-gql \
trozdol/server-gql
docker build . \
--no-cache \
--label web-app \
--tag trozdol/web-app
docker run \
--rm \
--env ENV=dev \
--publish 8081:80 \
--network alison-net \
--name web-app \
--hostname web-app \
trozdol/web-app
docker build
--no-cache \
--label db-api \
--name db-api \
--mount type=bind,src=./db-api/my.cnf,dst=/etc/my.cnf \
--mount type=bind,src=./db-api/data,dst=/var/lib/mysql \
-d mysql/mysql-server
docker run \
--rm \
--detach \
--network alison-net \
--publish 3306:3306 \
--hostname db-api \
--name=db-api \
mysql/mysql-server
docker build
--no-cache \
--label db-etl \
--name db-etl \
--mount type=bind,src=./db-etl/my.cnf,dst=/etc/my.cnf \
--mount type=bind,src=./db-etl/data,dst=/var/lib/mysql \
-d mysql/mysql-server
docker run \
--rm \
--detach \
--network alison-net \
--publish 3306:3306 \
--hostname db-etl \
--name=db-etl \
mysql/mysql-server