diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c97c16..4e2df21 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,6 @@ variables: DOCKER_TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$DOCKER_TAG DOCKER_PULL_SECRET: docker-registry-secret - MONGO_URL: $MONGO_URL cache: paths: @@ -22,9 +21,9 @@ build: image: maven:3.8.3-openjdk-17 stage: build variables: - MONGO_URL: $MONGO_URL + MONGO_URL: $DEV_MONGO_URL script: - - mvn $MAVEN_CLI_OPTS clean package -Pdocker + - mvn $MAVEN_CLI_OPTS clean package artifacts: paths: - target/json-schema-store-0.0.2.jar @@ -34,8 +33,6 @@ build_docker_image: services: - docker:dind stage: publish - variables: - MONGO_URL: $MONGO_URL script: - echo "$CI_DEPLOY_PASSWORD" | docker login $CI_REGISTRY -u $CI_DEPLOY_USER --password-stdin - echo $DOCKER_IMAGE_NAME @@ -49,16 +46,51 @@ build_docker_image: # script: # - mvn $MAVEN_CLI_OPTS test # -deploy: +deploy_dev: + variables: + NAMESPACE: biosamples-dev + HOST: wwwint.ebi.ac.uk + MONGO_URL: $DEV_MONGO_URL + VALIDATOR_URL: https://wwwdev.ebi.ac.uk/ait/biovalidator/validate + environment: + name: dev + url: https://wwwint.ebi.ac.uk/biosamples/schema-store + extends: .kube_deploy_script + +deploy_test: + variables: + NAMESPACE: biosamples-test + HOST: wwwdev.ebi.ac.uk + MONGO_URL: $TEST_MONGO_URL + VALIDATOR_URL: https://wwwdev.ebi.ac.uk/ait/biovalidator/validate + environment: + name: test + url: https://wwwdev.ebi.ac.uk/biosamples/schema-store + when: manual + extends: .kube_deploy_script + +deploy_prod: + variables: + NAMESPACE: biosamples-prod + HOST: www.ebi.ac.uk + MONGO_URL: $PROD_MONGO_URL + VALIDATOR_URL: https://wwwdev.ebi.ac.uk/ait/biovalidator/validate + environment: + name: prod + url: https://www.ebi.ac.uk/biosamples/schema-store + when: manual + extends: .kube_deploy_script + +.kube_deploy_script: stage: deploy - image: dtzar/helm-kubectl:3.11.0 + image: dtzar/helm-kubectl script: - - kubectl create namespace $KUBECTL_NAMESPACE || true - - kubectl config set-context --current --namespace=${KUBECTL_NAMESPACE} + - kubectl create namespace $NAMESPACE || true + - kubectl config set-context --current --namespace=${NAMESPACE} - kubectl delete secret $DOCKER_PULL_SECRET || true - kubectl create secret docker-registry $DOCKER_PULL_SECRET --docker-server=$CI_REGISTRY --docker-username=$CI_DEPLOY_USER --docker-password=$CI_DEPLOY_PASSWORD - - envsubst < deployment.yaml > kubernetes.yaml + - envsubst < k8s/deployment.yaml > kubernetes.yaml - kubectl apply -f kubernetes.yaml + - kubectl apply -f k8s/service.yaml - kubectl rollout restart deployments json-schema-store - when: manual diff --git a/Dockerfile b/Dockerfile index dc790d6..cddf5fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ FROM openjdk:17-jdk-slim EXPOSE 27017 ARG JAR_FILE=target/json-schema-store-0.0.2.jar COPY ${JAR_FILE} json-schema-store.jar -ENTRYPOINT ["java","-jar","/json-schema-store.jar", "--spring.profiles.active=docker"] +ENTRYPOINT ["java","-jar","/json-schema-store.jar"] diff --git a/k8s/.gitlab-ci.old.yml b/k8s/.gitlab-ci.old.yml deleted file mode 100644 index 132dbfc..0000000 --- a/k8s/.gitlab-ci.old.yml +++ /dev/null @@ -1,44 +0,0 @@ -image: maven:latest - -variables: - MAVEN_CLI_OPTS: "-DskipTests" - -cache: - paths: - - .m2/repository/ - - target/ - -stages: - - build -# - test - - deploy - -build: - stage: build - script: - - mvn $MAVEN_CLI_OPTS package -Pprod - artifacts: - paths: - - target/json-schema-store-0.0.1-SNAPSHOT.jar - -#test: -# stage: test -# script: -# - mvn $MAVEN_CLI_OPTS test -# -deploy: - image: ubuntu - stage: deploy - script: - - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )' - - eval $(ssh-agent -s) - - echo "$BSD_PROD_SSH_KEY" | tr -d '\r' | ssh-add - - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - ssh-keyscan ebi-cli >> ~/.ssh/known_hosts - - chmod 644 ~/.ssh/known_hosts - - ssh -v -o StrictHostKeyChecking=no tc_spo01@wp-p1m2-3d "rm -rf ~/deployments/sw/www/json-schema-store/*" - - scp -r -v -o StrictHostKeyChecking=no ./target/json-schema-store-*.jar tc_spo01@wp-p1m2-3d:~/deployments/sw/www/json-schema-store/json-schema-store.jar - - ssh -v -o StrictHostKeyChecking=no tc_spo01@wp-p1m2-3d "~/config/start.sh" -# only: -# - master \ No newline at end of file diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 30f5f29..f1fb442 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -2,37 +2,28 @@ apiVersion: apps/v1 kind: Deployment metadata: labels: - app: schema-store - name: schema-store + app: json-schema-store + name: json-schema-store spec: - replicas: 2 + replicas: 1 selector: matchLabels: - app: schema-store + app: json-schema-store template: metadata: labels: - app: schema-store + app: json-schema-store spec: imagePullSecrets: - name: $DOCKER_PULL_SECRET containers: - - name: schema-store + - name: json-schema-store image: $DOCKER_IMAGE_NAME imagePullPolicy: Always ports: - - containerPort: 8080 - ---- -apiVersion: v1 -kind: Service -metadata: - name: biovalidator-service -spec: - type: NodePort - selector: - app: schema-store - ports: - - protocol: TCP - port: 8080 - targetPort: 8080 \ No newline at end of file + - containerPort: 8085 + env: + - name: MONGO_URL + value: ${MONGO_URL} + - name: BIO_VALIDATOR_URL + value: ${VALIDATOR_URL} diff --git a/k8s/ingress_template.yaml b/k8s/ingress_template.yaml deleted file mode 100644 index fe9765c..0000000 --- a/k8s/ingress_template.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: schema-store-ingress - namespace: ${NAMESPACE} - labels: - app: schema-store-service - annotations: - nginx.ingress.kubernetes.io/rewrite-target: /$2 -spec: - ingressClassName: nginx - rules: - - host: ${HOST} - http: - paths: - - path: /ait/schemastore(/|$)(.*) - pathType: Prefix - backend: - service: - name: schema-store-service - port: - number: 8080 \ No newline at end of file diff --git a/k8s/service.yaml b/k8s/service.yaml index 5826ba7..3cf9b24 100644 --- a/k8s/service.yaml +++ b/k8s/service.yaml @@ -1,12 +1,12 @@ apiVersion: v1 kind: Service metadata: - name: schema-store + name: json-schema-store spec: type: NodePort selector: - app: schema-store + app: json-schema-store ports: - protocol: TCP - port: 8080 - targetPort: 8080 \ No newline at end of file + port: 8085 + targetPort: 8085 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml deleted file mode 100644 index b64af5c..0000000 --- a/src/main/resources/application-dev.yml +++ /dev/null @@ -1,23 +0,0 @@ -# MongoDB conf -spring: - data: - mongodb: - uri: mongodb://localhost:27017/schemastore - -# spring actuator -management: - endpoints: - web: - exposure: - include: "*" - -# Elixir Validator -schemastore: - validator: - url: https://wwwdev.ebi.ac.uk/ait/biovalidator/validate - -logging: - level: - org: - springframework: - security: DEBUG diff --git a/src/main/resources/application-docker.yml b/src/main/resources/application-docker.yml deleted file mode 100644 index 71e5fd3..0000000 --- a/src/main/resources/application-docker.yml +++ /dev/null @@ -1,18 +0,0 @@ -# MongoDB conf -spring: - data: - mongodb: - uri: ${MONGO_URL} -server: - port: 8085 -# spring actuator -management: - endpoints: - web: - exposure: - include: "*" - -# Elixir Validator -schemastore: - validator: - url: https://wwwdev.ebi.ac.uk/ait/biovalidator/validate diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml deleted file mode 100644 index 9f2607d..0000000 --- a/src/main/resources/application-prod.yml +++ /dev/null @@ -1,24 +0,0 @@ -# MongoDB conf -spring: - data: - mongodb: - port: 27017 - host: localhost - database: schemastore - repositories: - type: auto -# spring actuator -management: - endpoints: - web: - exposure: - include: "*" - -# Elixir Validator -schemastore: - validator: - url: http://localhost:3020/biosamples/schema/validator/validate - -server: - servlet: - context-path: /biosamples/schema/store \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1de05e0..d54dccc 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,18 +1,30 @@ +# MongoDB conf spring: - profiles: - active: dev mvc: pathmatch: matching-strategy: ant_path_matcher data: + mongodb: + uri: ${MONGO_URL} rest: basePath: /api/v2 +server: + port: 8085 + servlet: + context-path: /biosamples/schema-store # spring actuator management: endpoints: web: exposure: include: "*" + +# Elixir Validator +schemastore: + validator: + url: ${BIO_VALIDATOR_URL} + + logging: level: org: @@ -28,9 +40,3 @@ logging: ebi: biosamples: jsonschemastore: INFO - - -# Elixir Validator -schemastore: - validator: - url: http://localhost:3020/validate