Skip to content
Snippets Groups Projects
Commit 08e9ef38 authored by Yannis Barlas's avatar Yannis Barlas
Browse files

Merge branch 'main' of gitlab.coko.foundation:kotahi/kotahi into main

parents 408a0c6f 6f825500
No related branches found
No related tags found
No related merge requests found
variables:
IMAGE_ORG: kotahi
IMAGE_NAME: kotahi
ELIFE_SERVER_IP: 54.87.88.111
stages:
- build
- deploy
- test
build:
image: docker:20.10.5
variables:
DOCKER_BUILDKIT: 1
services:
- docker:20.10.5-dind
stage: build
before_script:
- cp app/brand-instances-configs/elife.json app/brandConfig.json
script:
- |
if [ -z "$DOCKERHUB_USERNAME_ELIFE" ] || [ -z "$DOCKERHUB_PASSWORD_ELIFE" ]; then echo "Not pushing" && exit 0; fi
docker login -u $DOCKERHUB_USERNAME_ELIFE -p $DOCKERHUB_PASSWORD_ELIFE
docker pull $IMAGE_ORG/$IMAGE_NAME:latest || true
docker build \
--file ./Dockerfile-production \
--cache-from $CI_REGISTRY_IMAGE:latest \
--tag $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA \
--tag $IMAGE_ORG/$IMAGE_NAME:latest .
docker build --file ./Dockerfile-ci --cache-from $IMAGE_ORG/$IMAGE_NAME-dev:latest --tag $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA --tag $IMAGE_ORG/$IMAGE_NAME-dev:latest .
docker push $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
docker push $IMAGE_ORG/$IMAGE_NAME:latest
docker push $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
docker push $IMAGE_ORG/$IMAGE_NAME-dev:latest
deploy:
stage: deploy
image: docker:19.03.13
before_script:
- export SSH_KEY=$SSH_KEY_ELIFE
- export DOCKERHUB_USERNAME=$DOCKERHUB_USERNAME_ELIFE
- export DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD_ELIFE
- export IMAGE_ORG=$IMAGE_ORG
- export IMAGE_NAME=$IMAGE_NAME
- eval $(ssh-agent -s)
- echo "$SSH_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $ELIFE_SERVER_IP >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- |
ssh ubuntu@$ELIFE_SERVER_IP "sudo docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD &&
sudo docker pull $IMAGE_ORG/$IMAGE_NAME:latest &&
sudo supervisorctl stop kotahi &&
cd /home/ubuntu/kotahi &&
sudo docker-compose down &&
sudo supervisorctl start kotahi"
lint:
allow_failure: true
image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
stage: test
variables:
GIT_STRATEGY: none
script:
- cd ${HOME}
- npm run lint
.test_template: &run_test_template
image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
stage: test
variables:
GIT_STRATEGY: none
# setup data for postgres image
POSTGRES_USER: kotahidev
POSTGRES_PASSWORD: kotahidev
# used by psql
PGUSER: kotahidev
PGPASSWORD: kotahidev
INSTANCE_NAME: elife
services:
- postgres
.script_template: &run_script_template
- cd ${HOME}
- apt-get -y install postgresql-client
# this is needed for pgboss initial setup
- psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# use the example env for tests
- cp .env.example .env
# specify host here else it confuses the linked postgres image
- POSTGRES_HOST=postgres yarn test:all:chrome:$TEST_ITEM
test-chrome:
<<: *run_test_template
variables:
TEST_ITEM: elife
script:
- *run_script_template
# .test_template: &run_test_template
# image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA
# stage: test
# variables:
# GIT_STRATEGY: none
# # setup data for postgres image
# POSTGRES_USER: kotahidev
# POSTGRES_PASSWORD: kotahidev
# # used by psql
# PGUSER: kotahidev
# PGPASSWORD: kotahidev
# # this is used to ignore self signed certs
# START_SERVER_AND_TEST_INSECURE: 1
# INSTANCE_NAME: elife
# services:
# - postgres
# #.script_template: &run_script_template
# # - cd ${HOME}
# # - apt-get -y install postgresql-client
# # # this is needed for pgboss initial setup
# # - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # # use the example env for tests
# # - cp .env.example .env
# # - # specify host here else it confuses the linked postgres image
# # - POSTGRES_HOST=postgres yarn test:all:chrome:$TEST_ITEM
# test-chrome:
# <<: *run_test_template
# variables:
# TEST_ITEM: elife
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:chrome:elife
# test-chrome-samsung:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:chrome:elife:samsung
# test-chrome-samsung-tablet:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:chrome:elife:samsung:tablet
# test-chrome-iPhone:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:chrome:elife:iPhone
# test-chrome-iPhone-tablet:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:chrome:elife:iPhone:tablet
# test-chrome-hd-laptop:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:chrome:elife:hd:laptop
# test-firefox:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:firefox:elife
# test-firefox-samsung:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:firefox:elife:samsung
# test-firefox-samsung-tablet:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:firefox:elife:samsung:tablet
# test-firefox-iPhone:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:firefox:elife:iPhone
# test-firefox-iPhone-tablet:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:firefox:elife:iPhone:tablet
# test-firefox-hd-laptop:
# <<: *run_test_template
# script:
# - cd ${HOME}
# - apt-get -y install postgresql-client
# # this is needed for pgboss initial setup
# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;"
# # use the example env for tests
# - cp .env.example .env
# # specify host here else it confuses the linked postgres image
# - POSTGRES_HOST=postgres yarn test:all:firefox:elife:hd:laptop
\ No newline at end of file
......@@ -23,7 +23,7 @@ build:
- |
if [ -z "$DOCKERHUB_USERNAME" ] || [ -z "$DOCKERHUB_PASSWORD" ]; then echo "Not pushing" && exit 0; fi
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
docker build --file ./Dockerfile-ci --cache-from $IMAGE_ORG/$IMAGE_NAME:latest --tag $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA --tag $IMAGE_ORG/$IMAGE_NAME:latest .
docker build --build-arg instance_name=coko --file ./Dockerfile-ci --cache-from $IMAGE_ORG/$IMAGE_NAME:latest --tag $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA --tag $IMAGE_ORG/$IMAGE_NAME:latest .
docker push $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
docker push $IMAGE_ORG/$IMAGE_NAME:latest
......
......@@ -23,6 +23,7 @@ build:
docker login -u $DOCKERHUB_USERNAME_ELIFE -p $DOCKERHUB_PASSWORD_ELIFE
docker pull $IMAGE_ORG/$IMAGE_NAME:latest || true
docker build \
--build-arg instance_name=elife \
--file ./Dockerfile-production \
--cache-from $CI_REGISTRY_IMAGE:latest \
--tag $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA \
......@@ -79,8 +80,6 @@ lint:
PGUSER: kotahidev
PGPASSWORD: kotahidev
INSTANCE_NAME: elife
services:
- postgres
.script_template: &run_script_template
- cd ${HOME}
......@@ -98,6 +97,8 @@ test-chrome:
TEST_ITEM: "chrome:elife"
script:
- *run_script_template
services:
- postgres
# test-chrome-samsung:
# <<: *run_test_template
......
FROM cypress/browsers:node14.16.0-chrome89-ff86
ARG instance_name
ENV NODE_ENV "development"
ENV SERVER_PROTOCOL "http"
ENV SERVER_HOST "0.0.0.0"
......@@ -7,7 +9,7 @@ ENV SERVER_PORT "3000"
ENV CLIENT_PROTOCOL "http"
ENV CLIENT_HOST "0.0.0.0"
ENV CLIENT_PORT "4000"
ENV INSTANCE_NAME "coko"
ENV INSTANCE_NAME $instance_name
ENV HOME "/home/simplej"
RUN mkdir -p ${HOME}
......
......@@ -18,7 +18,9 @@ RUN yarn install --frozen-lockfile --production=false
COPY . .
ENV INSTANCE_NAME "elife"
ARG instance_name
ENV INSTANCE_NAME $instance_name
ENV NODE_ENV "production"
ENV SERVER_PROTOCOL "http"
ENV SERVER_HOST "localhost"
......
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