Commit ccb153a4 authored by David Haynes's avatar David Haynes 🙆
Browse files

Merge branch '67-docker-swarm' into '2.1-dev'

Resolve "Docker Stack/Swarm Integration"

See merge request !27
parents 118b97b4 8a0111fe
Pipeline #1707 passed with stage
in 1 minute and 52 seconds
############################################################ ############################################################
# Dockerfile to build What's Open Django App # What's Open API v2
############################################################ ############################################################
# Set the base image to Ubuntu # Set the base image to Ubuntu
...@@ -10,8 +10,10 @@ ENV PYTHONUNBUFFERED 1 ...@@ -10,8 +10,10 @@ ENV PYTHONUNBUFFERED 1
RUN apt-get update RUN apt-get update
RUN apt-get install netcat libgdal1h libproj-dev proj-data proj-bin -y RUN apt-get install netcat libgdal1h libproj-dev proj-data proj-bin -y
RUN mkdir /whats_open # Copy over all project files into /whats_open
WORKDIR /whats_open RUN mkdir /whats-open/
ADD /requirements/ /whats_open/ WORKDIR /whats-open/
RUN pip install -r base.txt ADD . /whats-open/
ADD . /whats_open/
# Pip install all required dependecies
RUN pip install -r /whats-open/requirements/base.txt
...@@ -121,19 +121,17 @@ Additionally, you will need to install docker-compose: https://docs.docker.com/c ...@@ -121,19 +121,17 @@ Additionally, you will need to install docker-compose: https://docs.docker.com/c
Next inside the `whats-open/` root directory run: Next inside the `whats-open/` root directory run:
docker-compose build docker build . -t 'whats-open-api'
If that doesn't work, try: This builds the docker image that we will deploy to the swarm in a stack.
sudo docker-compose build Initialize your swarm:
Then, follow up with: docker swarm init
docker-compose up And finally,
If that doesn't work, try: docker stack deploy whats-open-api_stack -c docker-compose.yml
sudo docker-compose build
You should see that the server is running by going to http://localhost:8000 You should see that the server is running by going to http://localhost:8000
in your browser. Any changes you make to your local file system will be mirrored in the server. in your browser. Any changes you make to your local file system will be mirrored in the server.
......
version: '2' version: '3'
services: services:
wopen_web: db:
build: . image: mysql
restart: always deploy:
replicas: 1
restart_policy:
condition: on-failure
networks:
- wopen_net
ports:
- "3306:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: wopen
MYSQL_USER: wopen
MYSQL_PASSWORD: wopen
api:
image: whats-open-api
deploy:
replicas: 1
restart_policy:
condition: on-failure
networks:
- wopen_net
ports: ports:
- '8000:8000' - '8000:8000'
command: /bin/bash ./startup.sh command: /bin/bash ./startup.sh
volumes: volumes:
- .:/whats_open - .:/whats-open
depends_on: depends_on:
- wopen_db - db
environment: environment:
- WOPEN_EMAIL_DOMAIN=@masonlive.gmu.edu - WOPEN_EMAIL_DOMAIN=@masonlive.gmu.edu
- WOPEN_DB_NAME=wopen - WOPEN_DB_NAME=wopen
- WOPEN_DB_USER=wopen - WOPEN_DB_USER=wopen
- WOPEN_DB_PASSWORD=wopen - WOPEN_DB_PASSWORD=wopen
- WOPEN_DB_HOST=wopen_db - WOPEN_DB_HOST=db
- WOPEN_DB_PORT=3306 - WOPEN_DB_PORT=3306
- WOPEN_SUPERUSER=admin - WOPEN_SUPERUSER=admin
wopen_db:
image: mysql networks:
environment: wopen_net:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' \ No newline at end of file
MYSQL_DATABASE: wopen
MYSQL_USER: wopen
MYSQL_PASSWORD: wopen
\ No newline at end of file
until nc -z wopen_db 3306; do until nc -z db 3306; do
echo "waiting for database to start..." echo "waiting for database to start..."
sleep 1 sleep 1
done done
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment