Commit 6abf2517 authored by Matija Obreza's avatar Matija Obreza
Browse files

Gitlab CI

- Build docker image
- Deployment for reviews and sandbox environment
parent 49690280
variables:
IMAGE_VERSION: "1.9-SNAPSHOT"
IMAGE_VERSION: "0.1-SNAPSHOT"
DOCKER_HOST: "genesys1.swarm.genesys-pgr.org"
ARTIFACTS: "target/app"
......@@ -100,9 +100,10 @@ deploy for review:
when: manual
except:
- master
dependencies:
environment:
name: catalog/$CI_COMMIT_REF_SLUG
url: https://${CI_ENVIRONMENT_SLUG}.review.genesys-pgr.org
name: genesys/$CI_COMMIT_REF_SLUG
url: https://review.genesys-pgr.org/g/${CI_ENVIRONMENT_SLUG}
on_stop: remove review instance
before_script:
# Address the swarm
......@@ -123,10 +124,12 @@ deploy for review:
else
export IMAGE_TAG="${IMAGE_VERSION}-${CI_COMMIT_REF_SLUG}";
fi
- export CATALOG_API_URL=https://api.catalog.demo.genesys-pgr.org
- export CATALOG_FRONTEND_HOSTNAME=${CI_ENVIRONMENT_SLUG}.review.genesys-pgr.org
- echo "Deploying ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} for review as ${CATALOG_FRONTEND_HOSTNAME}"
- echo "Settings CLIENT_ID=${CATALOG_CLIENT_ID} CLIENT_SECRET=${CATALOG_CLIENT_SECRET}"
- export FRONTEND_HOSTNAME=review.genesys-pgr.org
- export FRONTEND_PATH=/g/${CI_ENVIRONMENT_SLUG}
- export FRONTEND_URL=https://${FRONTEND_HOSTNAME}${FRONTEND_PATH}
- export API_URL=https://sandbox.genesys-pgr.org
- echo "Deploying ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} for review as ${FRONTEND_URL}"
# - echo "Settings CLIENT_ID=${CLIENT_ID} CLIENT_SECRET=${CLIENT_SECRET}"
- envsubst < docker/review-compose-template.yml > review-composed.yml
- cat review-composed.yml
- ${DOCKER_CMD} stack rm ${CI_ENVIRONMENT_SLUG} || true
......@@ -140,12 +143,13 @@ remove review instance:
- master
variables:
GIT_STRATEGY: none
dependencies:
environment:
name: catalog/$CI_COMMIT_REF_SLUG
url: https://${CI_ENVIRONMENT_SLUG}.review.genesys-pgr.org
name: genesys/$CI_COMMIT_REF_SLUG
url: https://review.genesys-pgr.org/g/${CI_ENVIRONMENT_SLUG}
action: stop
before_script:
- echo Removing review https\://${CI_ENVIRONMENT_SLUG}.review.genesys\-pgr.org
- echo Removing review https://review.genesys\-pgr.org/g/${CI_ENVIRONMENT_SLUG}
# Address the swarm
- export DOCKER_HOST=swarm.genesys-pgr.org
# Configuration
......@@ -163,6 +167,9 @@ remove review instance:
deploy to sandbox:
stage: deploy
image: docker:latest
variables:
GIT_STRATEGY: none
dependencies:
only:
- master
before_script:
......@@ -178,7 +185,7 @@ deploy to sandbox:
- DOCKER_CMD=docker
script:
# Actions
- ${DOCKER_CMD} service update --image ${CI_REGISTRY_IMAGE}:${IMAGE_VERSION} catalog-sandbox_frontend
- ${DOCKER_CMD} service update --image ${CI_REGISTRY_IMAGE}:${IMAGE_VERSION} genesysuidemo
environment:
name: sandbox
url: https://catalog.demo.genesys-pgr.org
url: https://genesys.demo.genesys-pgr.org
......@@ -12,10 +12,10 @@ RUN apk add --no-cache gettext
RUN npm install pm2 -g
# Entrypoint and template
COPY ssr.sh catalogui-pm2.yml /
COPY ssr.sh genesys-pm2.yml /
ENV USER=nobody \
APP_PATH=/var/www/genesys-catalog-ui
APP_PATH=/var/www/genesys-ui
# Application
COPY app ${APP_PATH}/
......
apps:
- script: server.js
args: >-
--api-url=${CATALOG_API_URL}
--frontend-path=${FRONTEND_PATH}
--api-url=${API_URL}
--api-timeout=${API_TIMEOUT}
--client-id=${CLIENT_ID} --client-secret=${CLIENT_SECRET}
--client-id=${CLIENT_ID}
--client-secret=${CLIENT_SECRET}
--geonames-username=${GEONAMES_USERNAME}
--genesys-url=${GENESYS_URL}
--genesys-client-id=${GENESYS_CLIENT_ID}
--genesys-client-secret=${GENESYS_CLIENT_SECRET}
name: catalogui
name: genesysui
exec_mode: cluster
instances: 3
log_type: raw
cwd: /var/www/genesys-catalog-ui/server
cwd: /var/www/genesys-ui/server
env:
NODE_ENV: production
......@@ -4,9 +4,10 @@ services:
frontend:
image: ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
environment:
- "CLIENT_ID=${CATALOG_CLIENT_ID}"
- "CLIENT_SECRET=${CATALOG_CLIENT_SECRET}"
- "CATALOG_API_URL=${CATALOG_API_URL}"
- "FRONTEND_PATH=${FRONTEND_PATH}"
- "API_URL=${API_URL}"
- "CLIENT_ID=${CLIENT_ID}"
- "CLIENT_SECRET=${CLIENT_SECRET}"
- "GEONAMES_USERNAME=${GEONAMES_USERNAME}"
- "SSR=true"
- "ALLOW_ROBOTS=false"
......@@ -17,7 +18,7 @@ services:
labels:
- traefik.port=3000
- traefik.docker.network=traefik-net
- traefik.frontend.rule=Host:${CATALOG_FRONTEND_HOSTNAME}
- "traefik.frontend.rule=Host:${FRONTEND_HOSTNAME};PathPrefixStrip:${FRONTEND_PATH}"
resources:
limits:
memory: 300m
......
#!/bin/sh
echo "Running Genesys Catalog UI from `pwd` with CLIENT_ID=${CLIENT_ID} and API at ${CATALOG_API_URL}"
echo "Running Genesys UI from `pwd` with CLIENT_ID=${CLIENT_ID} and API at ${API_URL}"
echo "Starting on TCP port ${PORT} (default 3000)."
envsubst < /catalogui-pm2.yml > catalogui-pm2.yml
envsubst < /genesys-pm2.yml > genesys-pm2.yml
exec pm2-docker start catalogui-pm2.yml
exec pm2-docker start genesys-pm2.yml
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