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

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

Resolve "Docker Stack/Swarm Integration"

See merge request srct/whats-open!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
......@@ -10,8 +10,10 @@ ENV PYTHONUNBUFFERED 1
RUN apt-get update
RUN apt-get install netcat libgdal1h libproj-dev proj-data proj-bin -y
RUN mkdir /whats_open
WORKDIR /whats_open
ADD /requirements/ /whats_open/
RUN pip install -r base.txt
ADD . /whats_open/
# Copy over all project files into /whats_open
RUN mkdir /whats-open/
WORKDIR /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
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:
sudo docker-compose build
docker stack deploy whats-open-api_stack -c docker-compose.yml
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.
......
version: '2'
version: '3'
services:
wopen_web:
build: .
restart: always
db:
image: mysql
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:
- '8000:8000'
command: /bin/bash ./startup.sh
volumes:
- .:/whats_open
- .:/whats-open
depends_on:
- wopen_db
- db
environment:
- WOPEN_EMAIL_DOMAIN=@masonlive.gmu.edu
- WOPEN_DB_NAME=wopen
- WOPEN_DB_USER=wopen
- WOPEN_DB_PASSWORD=wopen
- WOPEN_DB_HOST=wopen_db
- WOPEN_DB_HOST=db
- WOPEN_DB_PORT=3306
- WOPEN_SUPERUSER=admin
wopen_db:
image: mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: wopen
MYSQL_USER: wopen
MYSQL_PASSWORD: wopen
\ No newline at end of file
networks:
wopen_net:
\ 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..."
sleep 1
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