Fakultas Ilmu Komputer UI

Commit 34549f16 authored by Bayukanta Iqbal Gunawan's avatar Bayukanta Iqbal Gunawan
Browse files

Tes docker

parent 124b0753
Pipeline #48535 failed with stages
in 2 minutes
variables:
POSTGRES_DB: $DB_NAME
POSTGRES_USER: $DB_USER
POSTGRES_PASSWORD: $DB_PASSWORD
POSTGRES_HOST_AUTH_METHOD: $DB_HOST_AUTH_METHOD
services:
- postgres:12.2-alpine
stages: stages:
- test - test
- linter - linter
- sonarqube - sonarqube
- deploy - staging
- production
UnitTest: UnitTest:
image: python:3.7 image: python:3.7
...@@ -45,7 +55,7 @@ SonarScanner: ...@@ -45,7 +55,7 @@ SonarScanner:
Staging: Staging:
image: ruby:2.4 image: ruby:2.4
stage: deploy stage: staging
only: only:
refs: refs:
- staging - staging
...@@ -63,17 +73,27 @@ Staging: ...@@ -63,17 +73,27 @@ Staging:
Deployment: Deployment:
image: ruby:2.4 image: ruby:2.4
stage: deploy stage: production
only: only:
refs: refs:
- master - docker
before_script: before_script:
- gem install dpl - apt-get update -qq
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh - apt-get install -qq git
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script: script:
- dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY - >
- export HEROKU_API_KEY=$HEROKU_APIKEY ssh admin@10.119.106.12
- heroku run --app $HEROKU_APPNAME migrate "cd poipole-dtb-beasiswa-miskin-dan-disabilitas &&
git checkout docker &&
git pull origin docker &&
bash stop.sh &&
bash start.sh &&
exit"
environment: environment:
name: production name: production
url: $HEROKU_APP_HOST url: $VM_URL
FROM node:latest
WORKDIR /opt/pplbackend
RUN mkdir -p /opt/pplbackend
ADD . /opt/pplbackend
RUN \
apt-get update && \
apt-get -y install python3 python3-pip && \
python3 -m pip install -r requirements.txt --no-cache-dir
RUN chmod +x /opt/pplbackend/docker_start.sh
EXPOSE 8000
version: "3"
services:
pplbackend:
build: .
restart: always
entrypoint: /opt/pplbackend/docker_start.sh
environment:
- DB_NAME=bisago
- DB_USER=bisago
- DB_PASSWORD=poipole
- DB_HOST=bisago_db
- DB_PORT=5432
ports:
- "8000:8000"
depends_on:
- bisago_db
bisago_db:
image: postgres
restart: always
ports:
- "5432"
environment:
- POSTGRES_DB=bisago
- POSTGRES_USER=bisago
- POSTGRES_PASSWORD=poipole
#!/bin/bash
python3 manage.py makemigrations rest_framework_jwt
python3 manage.py migrate
gunicorn pplbackend.wsgi --bind 0.0.0.0:8000
\ No newline at end of file
...@@ -96,8 +96,12 @@ WSGI_APPLICATION = 'pplbackend.wsgi.application' ...@@ -96,8 +96,12 @@ WSGI_APPLICATION = 'pplbackend.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'NAME': os.environ.get('DB_NAME', 'postgres'),
'USER': os.environ.get('DB_USER', 'postgres'),
'PASSWORD': os.environ.get('DB_PASSWORD', 'postgres'),
'HOST': os.environ.get('DB_HOST', 'localhost'),
'PORT': os.environ.get('DB_PORT', '5432'),
} }
} }
......
#!/bin/bash
echo "Starting bisago ..."
env/bin/pip3 install -r requirements.txt
env/bin/python3 manage.py migrate
sudo env/bin/python3 manage.py runserver 0:80 >out 2>&1 &
#!/bin/bash
PID=$(ps ax | grep manage.py | grep -v grep | head -n1 | awk '{print $1}')
if [[ $PID ]]
then
echo "Stopping bisago ..."
ps ax | grep manage.py | grep -v grep | head -n1 | awk '{print $1}' | xargs sudo kill -TERM
else
echo "bisago is not running ..."
fi
Supports Markdown
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