Skip to content

Commit

Permalink
#396 Fix intersection of docker up and drone services (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
duker33 committed Jul 7, 2018
1 parent daee6d9 commit cc7b6ce
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ pipeline:
status: [ success, failure ]
event: [push, pull_request]

docker-up:
image: docker/compose:1.17.1
commands:
- cd docker
- cp drone_env/* env_files/
- cp drone_env/.env .
- docker-compose up -d app
# @todo #396:60m Do drone check `docker-up` service.
# Let drone check if started service is available.
# Some code draft:
# `- if [[ $(curl -Is http://127.0.0.1:8010 | head -1 | grep 200) = '' ]]; then echo 'service '; fi`
- docker-compose stop
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# for nodejs build
- /tmp/cache/drone/shopelectro/front_build/${DRONE_COMMIT_SHA}:/drone/src/github.com/fidals/shopelectro/front/build
when:
event: [push, pull_request]

npm-clean:
image: busybox
commands:
Expand Down
6 changes: 3 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ services:
networks:
- se-backend
ports:
- 5673:$RABBITMQ_PORT
- 15673:15672
- 5675:$RABBITMQ_PORT
- 15675:15672

redis:
image: redis:alpine
Expand All @@ -76,7 +76,7 @@ services:
networks:
- se-backend
ports:
- 6380:6379
- 6382:6379

selenium:
image: selenium/standalone-chrome-debug:3.10.0
Expand Down
57 changes: 57 additions & 0 deletions docker/drone_env/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Both .env and env_files/ are needed because of docker-compose realization.
# See good explanation here:
# https://github.com/docker/compose/issues/4223#issuecomment-280077263

# Docs here: https://docs.docker.com/compose/environment-variables/#/the-env-file

COMPOSE_PROJECT_NAME=drone_shopelectro
# It may affect on app logic. Valid values: LOCAL | CI | PROD
ENV_TYPE=LOCAL

# App related settings
DJANGO_SETTINGS_MODULE=shopelectro.settings.local
DJANGO_LOG_LEVEL=INFO
SECRET_KEY=secret-key
STAGE_SECRET_KEY=another-secret-key

# URL to required services
POSTGRES_URL=postgres
REDIS_URL=redis
REDIS_PORT=6379
RABBITMQ_URL=rabbitmq
RABBITMQ_PORT=5672
# Docs here: https://docs.docker.com/compose/environment-variables/#/the-env-file

# Credentials for app's services
POSTGRES_USER=postgres
POSTGRES_PASSWORD=pass
POSTGRES_DB=se_prod
POSTGRES_INITDB_XLOGDIR=/var/lib/postgresql/xlog
STAGE_DB_NAME=se_stage
RABBITMQ_DEFAULT_USER=user
RABBITMQ_DEFAULT_PASS=pass
REDIS_PASSWORD=pass

# Credentials for ftp with files from 1C
FTP_PASS
FTP_USER=1c_exc
FTP_IP=37.18.77.165

# Credentials for yandex services
YANDEX_SHOP_PASS=pass
EMAIL_HOST_PASSWORD=pass
# Identify the dependencies folder
DEPS_DIR=/usr/local/lib/python3.6/site-packages
# Identify the source folder
SRC_DIR=/usr/app/src
SRC_DIR_PROD=/home/andre/prog/shopelectro

REFARM_DIR=../../refarm-site
POSTGRES_DATA_DIR=/var/fidals/se_db
FRONT_BUILD_DIR=/usr/app/front/build
# Exposed ports
VIRTUAL_HOST_PORT=8000
VIRTUAL_HOST_EXPOSE_PORT=8012
VIRTUAL_HOST_LIVESERVER_PORT=8020-8030
VIRTUAL_HOST_STAGE_PORT=8001
VIRTUAL_HOST_STAGE_EXPOSE_PORT=8011
18 changes: 18 additions & 0 deletions docker/drone_env/app
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Docs here: https://docs.docker.com/compose/environment-variables/#/the-env-file

COMPOSE_PROJECT_NAME=drone_shopelectro
# It may affect on app logic. Valid values: LOCAL | CI | PROD
ENV_TYPE=LOCAL

# App related settings
DJANGO_SETTINGS_MODULE=shopelectro.settings.local
DJANGO_LOG_LEVEL=INFO
SECRET_KEY=secret-key
STAGE_SECRET_KEY=another-secret-key

# URL to required services
POSTGRES_URL=postgres
REDIS_URL=redis
REDIS_PORT=6379
RABBITMQ_URL=rabbitmq
RABBITMQ_PORT=5672
20 changes: 20 additions & 0 deletions docker/drone_env/credentials
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Docs here: https://docs.docker.com/compose/environment-variables/#/the-env-file

# Credentials for app's services
POSTGRES_USER=postgres
POSTGRES_PASSWORD=pass
POSTGRES_DB=se_prod
POSTGRES_INITDB_XLOGDIR=/var/lib/postgresql/xlog
STAGE_DB_NAME=se_stage
RABBITMQ_DEFAULT_USER=user
RABBITMQ_DEFAULT_PASS=pass
REDIS_PASSWORD=pass

# Credentials for ftp with files from 1C
FTP_PASS
FTP_USER=1c_exc
FTP_IP=37.18.77.165

# Credentials for yandex services
YANDEX_SHOP_PASS=pass
EMAIL_HOST_PASSWORD=pass
9 changes: 9 additions & 0 deletions docker/drone_env/paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Identify the dependencies folder
DEPS_DIR=/usr/local/lib/python3.6/site-packages
# Identify the source folder
SRC_DIR=/usr/app/src
SRC_DIR_PROD=/home/andre/prog/shopelectro

REFARM_DIR=../../refarm-site
POSTGRES_DATA_DIR=/var/fidals/se_db
FRONT_BUILD_DIR=/usr/app/front/build
6 changes: 6 additions & 0 deletions docker/drone_env/ports
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Exposed ports
VIRTUAL_HOST_PORT=8000
VIRTUAL_HOST_EXPOSE_PORT=8012
VIRTUAL_HOST_LIVESERVER_PORT=8020-8030
VIRTUAL_HOST_STAGE_PORT=8001
VIRTUAL_HOST_STAGE_EXPOSE_PORT=8011

1 comment on commit cc7b6ce

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on cc7b6ce Jul 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 396-93372351 discovered in .drone.yml and submitted as #408. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.