Commit ab1e6670 authored by Guillaume Cornut's avatar Guillaume Cornut Committed by Raphaël Flores
Browse files

chore: Configure continuous delivery in `.gitlab-ci.yml`. Change default context path and port.

parent f760a76d
---
stages:
- test
- build
- staging
- production
image: urgi/docker-browsers:latest
# Disable the Gradle daemon for Continuous Integration servers as correctness
......@@ -7,14 +14,16 @@ image: urgi/docker-browsers:latest
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
GRADLE_USER_HOME: $CI_PROJECT_DIR/.gradle
APP_NAME: gpds
JAR_PATH: "backend/build/libs/${APP_NAME}.jar"
# Gradle cache for all jobs
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- ".gradle"
- "frontend/.gradle/"
- "frontend/node_modules/"
- ".gradle"
- "frontend/.gradle/"
- "frontend/node_modules/"
# TESTS
......@@ -28,7 +37,7 @@ test-frontend:
artifacts:
reports:
junit:
- "./frontend/karma-junit-tests-report/TEST*.xml"
- "./frontend/karma-junit-tests-report/TEST*.xml"
test-backend:
stage: test
......@@ -52,3 +61,127 @@ test-backend:
junit:
- "./backend/build/test-results/test/TEST-*.xml"
# BUILD
build:
stage: build
script:
- ./gradlew assemble
artifacts:
paths:
- "$JAR_PATH"
expire_in: 1 week
only:
changes:
- backend/src/**/*
- frontend/**/*
# DEPLOY
.deploy-to-vm: &deploy_to_vm
# Hidden job which serves as template for executed jobs below.
# See https://docs.gitlab.com/ee/ci/yaml/#anchors
retry: 2
## SSH initialization
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "${SSH_PRIVATE_KEY}")
- ssh -o StrictHostKeyChecking=no root@${SERVER_IP} 'echo "Successfully connected on $(hostname)"'
script:
# Copy jar and data (cleaning them before) to the server
- "scp ./$JAR_PATH root@${SERVER_IP}:/opt/${APP_NAME}/${APP_NAME}-${ENV}.jar"
# Restarting service with the updated jar and the according Spring profiles enabled
- "ssh root@${SERVER_IP} \"systemctl restart ${APP_NAME}-${ENV}\""
- eval $(ssh-agent -k)
- "echo \"Deploy done. Application should be available at: http://${SERVER_IP}:${APP_PORT}/${CONTEXT_PATH} \""
only:
changes:
- backend/src/**/*
- frontend/**/*
deploy-to-prod:
stage: production
variables:
ENV: prod
APP_PORT: ${PROD_GPDS_PORT}
CONTEXT_PATH: ${PROD_GPDS_CONTEXT_PATH}
<<: *deploy_to_vm
only:
refs:
- master
when: manual
allow_failure: false
deploy-to-beta:
stage: staging
variables:
ENV: beta
APP_PORT: ${BETA_GPDS_PORT}
CONTEXT_PATH: ${BETA_GPDS_CONTEXT_PATH}
<<: *deploy_to_vm
only:
refs:
- branches
except:
refs:
- master
allow_failure: false
deploy-to-staging:
stage: staging
variables:
ENV: staging
APP_PORT: ${STAGING_GPDS_PORT}
CONTEXT_PATH: ${STAGING_GPDS_CONTEXT_PATH}
<<: *deploy_to_vm
only:
refs:
- master
deploy-to-private-prod:
stage: production
variables:
ENV: private-prod
APP_PORT: ${PRIVATE_PROD_GPDS_PORT}
CONTEXT_PATH: ${PRIVATE_PROD_GPDS_CONTEXT_PATH}
<<: *deploy_to_vm
only:
refs:
- master
when: manual
allow_failure: false
deploy-to-private-int:
stage: production
variables:
ENV: private-int
APP_PORT: ${PRIVATE_INT_GPDS_PORT}
CONTEXT_PATH: ${PRIVATE_INT_GPDS_CONTEXT_PATH}
<<: *deploy_to_vm
only:
refs:
- master
when: manual
allow_failure: false
deploy-to-private-beta:
stage: staging
variables:
ENV: private-beta
APP_PORT: ${PRIVATE_BETA_GPDS_PORT}
CONTEXT_PATH: ${PRIVATE_BETA_GPDS_CONTEXT_PATH}
<<: *deploy_to_vm
only:
refs:
- branches
except:
refs:
- master
when: manual
allow_failure: false
......@@ -68,7 +68,7 @@ Otherwise, for the complete server (backend APIs + frontend interface), you can
./gradlew assemble && java -jar backend/build/libs/gpds.jar
```
The server should then be accessible at http://localhost:8080/gnpis-core
The server should then be accessible at http://localhost:8060/gnpis/gpds
## Run frontend development server
......@@ -110,18 +110,28 @@ If such a configuration is not found, it will then fallback to the local `applic
To avoid running the Spring Cloud config server every time when developing the application,
all the properties are still available in `application.yml` even if they are configured on the remote Spring Cloud server as well.
> **TODO**: Create a sping cloud configuration git repository and update the following section:
> If you want to use the Spring Cloud config app locally,
If you want to use the Spring Cloud config app locally,
see https://forgemia.inra.fr/urgi-is/data-discovery-config
> The configuration is currently only read on startup,
The configuration is currently only read on startup,
meaning the application has to be reboot if the configuration is changed on the Spring Cloud server.
For a dynamic reload without restarting the application,
see http://cloud.spring.io/spring-cloud-static/Finchley.SR1/single/spring-cloud.html#refresh-scope
to check what has to be changed.
> In case of testing configuration from the config server, one may use a dedicated branch on `data-discovery-config` project
In case of testing configuration from the config server, one may use a dedicated branch on `data-discovery-config` project
and append the `--spring.cloud.config.label=<branch name to test>` parameter when starting the application's executable jar.
More info on how pass a parameter to a Spring Boot app:
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config
### Application port & context path
| | GPDS GnpIS |
| :------------: | :---------------------- |
| dev | :8060/gnpis/gpds |
| beta | :8061/gnpis/gpds-beta |
| staging | :8062/staging/gnpis/gpds |
| prod | :8063/gnpis/gpds |
| private prod | :8064/private/gnpis/gpds |
| private beta | :8065/beta/gnpis/gpds |
| private int | :8066/int/gnpis/gpds |
......@@ -52,7 +52,7 @@ gpds:
security-user-group-ws-token:
server:
port: 8080
port: 8060
servlet:
context-path: /gnpis-core
context-path: /gnpis/gpds
......@@ -42,7 +42,7 @@
"node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css"
],
"scripts": [],
"baseHref": "/gnpis-core/"
"baseHref": "/gnpis/gpds/"
},
"configurations": {
"production": {
......
const PROXY_CONFIG = [
{
context: [
"/gnpis-core/brapi",
"/gnpis-core/gnpis",
"/gnpis/gpds/brapi",
"/gnpis/gpds/gnpis",
],
target: "http://localhost:8080",
target: "http://localhost:8060",
secure: false
}
];
......
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