diff --git a/._gitlab-ci.elife.yml b/._gitlab-ci.elife.yml deleted file mode 100644 index 9b924f5105128597317114085da28b747876d8c7..0000000000000000000000000000000000000000 --- a/._gitlab-ci.elife.yml +++ /dev/null @@ -1,273 +0,0 @@ -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 diff --git a/.gitlab-ci.coko.yml b/.gitlab-ci.coko.yml index d3b54c0bf373a44199a2efcd95f9dba5ee0da379..f8689c2fedbce146070e783e3982e67099498887 100644 --- a/.gitlab-ci.coko.yml +++ b/.gitlab-ci.coko.yml @@ -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 diff --git a/.gitlab-ci.elife.yml b/.gitlab-ci.elife.yml index 5398fc4970e6d81f450c86e63b9626d18031feb4..33367b96f5e064ff3190a65d358cde92dec63916 100644 --- a/.gitlab-ci.elife.yml +++ b/.gitlab-ci.elife.yml @@ -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 diff --git a/Dockerfile-ci b/Dockerfile-ci index 4be083a1764462420697f3e6c0cb373f9392e686..36f886bb5eb3a46d8b1e2658af62d00cbe900951 100644 --- a/Dockerfile-ci +++ b/Dockerfile-ci @@ -1,5 +1,7 @@ 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} diff --git a/Dockerfile-production b/Dockerfile-production index 361ce271f92b02ef2b22429553b901b82da166c4..1e9a840db0efa76d0c73b61f315b174e017d2415 100644 --- a/Dockerfile-production +++ b/Dockerfile-production @@ -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"