Commit 7ffc9474 by Chif Gergő

Add ci stages and stagigng deployment

parent 915ac7b4
Pipeline #1280 passed with stages
in 4 minutes 11 seconds
...@@ -12,7 +12,7 @@ DJANGO_SETTINGS_MODULE=myproject.settings.local ...@@ -12,7 +12,7 @@ DJANGO_SETTINGS_MODULE=myproject.settings.local
DATABASE_PASSWORD=database_password DATABASE_PASSWORD=database_password
DATABASE_USER=user DATABASE_USER=user
DATABASE_NAME=user DATABASE_NAME=user
DATABASE_HOST=hostname_of_batabase DATABASE_HOST=hostname_of_database
# For channels communication and periodic tasks we need a redis server # For channels communication and periodic tasks we need a redis server
REDIS_HOST=redis_host REDIS_HOST=redis_host
......
...@@ -6,16 +6,38 @@ before_script: ...@@ -6,16 +6,38 @@ before_script:
- git submodule sync --recursive - git submodule sync --recursive
- git submodule update --init --recursive - git submodule update --init --recursive
stages:
- testing
- build
- deploy
flake8: flake8:
stage: testing
script: script:
- python3.6 -m pip install flake8 - python3.6 -m pip install flake8
- flake8 - flake8
build-local: test:
stage: testing
script: script:
- docker build --tag recircle-backend:1.0 . - docker build --tag recircle-backend-local:latest .
- docker run recircle-backend-local:latest pipenv run python manage.py test
test: build_prod_image:
stage: build
script: script:
- docker build --tag recircle-backend:1.0 . - docker build -f ./Dockerfile.prod --tag recircle-backend:latest .
- docker run recircle-backend:1.0 pipenv run python manage.py test
# deploy needs sshpass installed on gitlab runner machince
deploy_staging:
stage: deploy
tags:
- ssh-deploy-staging
script: # When the docker registry ready, pull images from it
- docker-compose -f docker-compose.prod.yml up -d --build
environment:
name: staging
url: http://vm.niif.cloud.bme.hu:20088
only:
- DEV
- master
...@@ -9,6 +9,7 @@ EXPOSE 8000/tcp ...@@ -9,6 +9,7 @@ EXPOSE 8000/tcp
COPY Pipfile* .env ./ COPY Pipfile* .env ./
# This env variable needed to pipenv find .env file # This env variable needed to pipenv find .env file
ENV PIPENV_DOTENV_LOCATION=/usr/cloud/portal/.env ENV PIPENV_DOTENV_LOCATION=/usr/cloud/portal/.env
ENV DJANGO_SETTINGS_MODULE=recircle.settings.local
# Install dependencies # Install dependencies
RUN pipenv install -d RUN pipenv install -d
# Copy sources # Copy sources
......
...@@ -9,6 +9,7 @@ EXPOSE 8000/tcp ...@@ -9,6 +9,7 @@ EXPOSE 8000/tcp
COPY Pipfile* .env ./ COPY Pipfile* .env ./
# This env variable needed to pipenv find .env file # This env variable needed to pipenv find .env file
ENV PIPENV_DOTENV_LOCATION=/usr/cloud/portal/.env ENV PIPENV_DOTENV_LOCATION=/usr/cloud/portal/.env
ENV DJANGO_SETTINGS_MODULE=recircle.settings.prod
# Install dependencies # Install dependencies
RUN pipenv install RUN pipenv install
# Copy sources # Copy sources
......
...@@ -19,6 +19,8 @@ services: ...@@ -19,6 +19,8 @@ services:
POSTGRES_PASSWORD: ${DATABASE_PASSWORD} POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_USER: ${DATABASE_USER} POSTGRES_USER: ${DATABASE_USER}
POSTGRES_DB: ${DATABASE_NAME} POSTGRES_DB: ${DATABASE_NAME}
volumes:
- /database/recircle:/var/lib/postgresql/data
networks: networks:
- backend - backend
......
#!/bin/bash #!/bin/bash
## This file used by the gitlab ci runner
## Reads the environment variables from the CI config then echoes it to the .env file
# This variables are interpreted automatically by the Docker Engine # This variables are interpreted automatically by the Docker Engine
# And by the Django runtime # And by the Django runtime
# Django configuration # Django configuration
echo DJANGO_SECRET=${DJANGO_SECRET} >> .env echo DJANGO_SECRET=${DJANGO_SECRET} >> .env
echo DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE} >> .env
# If using other database than sqlite3 (only use sqlite for development!) # If using other database than sqlite3 (only use sqlite for development!)
# Provide the db credentials here # Provide the db credentials here
echo DATABASE_PASSWORD=${DATABASE_PASSWORD} >> .env echo DATABASE_PASSWORD=${DATABASE_PASSWORD} >> .env
......
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 sign in to comment