Commit 5bb3e6e6 authored by Matija Obreza's avatar Matija Obreza
Browse files

Gitlab CI

parent 52dc145e
Pipeline #1418 passed with stages
/target/
.awesome-typescript-loader-cache/
node_modules
variables:
IMAGE_VERSION: "1.0"
DOCKER_HOST: "genesys1.swarm.genesys-pgr.org"
ARTIFACTS: "target/www"
stages:
- package
- dockerize
# - deploy
# - undeploy
.package_template: &node_package
image: node:8.1-alpine
before_script:
- npm install
artifacts:
name: "${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}"
expire_in: 1 day
paths:
- ${ARTIFACTS}
package master or tag:
<<: *node_package
stage: package
script:
- npm run build:target
only:
- master
- tags
package the branch:
<<: *node_package
stage: package
when: manual
allow_failure: false
script:
- npm run build:target
except:
- master
- tags
.docker_image_template: &docker_image
image: docker:latest
before_script:
- echo Building docker image ${CI_REGISTRY_IMAGE} on ${DOCKER_HOST}
- echo Registry ${CI_REGISTRY} user=${CI_REGISTRY_USER} ${CI_REGISTRY_PASSWORD}
script:
# Configuration
- TLS_PATH=~/.docker/${DOCKER_HOST}/certs && mkdir -p ${TLS_PATH}
- echo "${DOCKER_TLS_CA}" > ${TLS_PATH}/ca.pem
- echo "${DOCKER_TLS_KEY}" > ${TLS_PATH}/key.pem
- echo "${DOCKER_TLS_CERT}" > ${TLS_PATH}/cert.pem
- export DOCKER_TLS_VERIFY=1
- export DOCKER_CERT_PATH=${TLS_PATH}
- DOCKER_CMD="docker --tlsverify=false"
# - ls -la ${DOCKER_CERT_PATH}
# - set | grep DOCKER
# Actions
- cp -r ${ARTIFACTS} docker
# - find docker -type f -exec ls -l {} \;
- cd docker
- if [ "${CI_COMMIT_REF_SLUG}" = "master" ] ; then
export IMAGE_TAG="${IMAGE_VERSION}";
else
export IMAGE_TAG="${IMAGE_VERSION}-${CI_COMMIT_REF_SLUG}";
fi
- "echo The image tag: ${IMAGE_TAG}"
- ${DOCKER_CMD} build -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
- ${DOCKER_CMD} login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- ${DOCKER_CMD} push ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
- ${DOCKER_CMD} logout $CI_REGISTRY
dockerize master or tag:
<<: *docker_image
stage: dockerize
dependencies:
- package master or tag
only:
- master
- tags
dockerize the branch:
<<: *docker_image
stage: dockerize
dependencies:
- package the branch
# when: manual
allow_failure: false
except:
- master
- tags
# deploy for review:
# stage: deploy
# image: docker:latest
# # when: manual
# allow_failure: false
# environment:
# name: review/$CI_COMMIT_REF_SLUG
# url: https://catalogui-${CI_COMMIT_REF_SLUG}.review.genesys-pgr.org
# on_stop: remove review instance
# script:
# # Address the swarm
# - export DOCKER_HOST=swarm.genesys-pgr.org
# # Configuration
# - TLS_PATH=~/.docker/${DOCKER_HOST}/certs && mkdir -p ${TLS_PATH}
# - echo "${DOCKER_TLS_CA}" > ${TLS_PATH}/ca.pem
# - echo "${DOCKER_TLS_KEY}" > ${TLS_PATH}/key.pem
# - echo "${DOCKER_TLS_CERT}" > ${TLS_PATH}/cert.pem
# - export DOCKER_TLS_VERIFY=1
# - export DOCKER_CERT_PATH=${TLS_PATH}
# - DOCKER_CMD=docker
# # Actions
# - if [ "${CI_COMMIT_REF_SLUG}" = "master" ] ; then
# export IMAGE_TAG="${IMAGE_VERSION}";
# else
# export IMAGE_TAG="${IMAGE_VERSION}-${CI_COMMIT_REF_SLUG}";
# fi
# - echo Deploying ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} for review as https\://catalogui-${CI_COMMIT_REF_SLUG}.review.genesys\-pgr.org
# - ${DOCKER_CMD} stack deploy -c review-composed.yml catalogui-${CI_COMMIT_REF_SLUG}-review
#
# remove review instance:
# stage: undeploy
# image: docker:latest
# when: manual
# variables:
# GIT_STRATEGY: none
# environment:
# name: review/$CI_COMMIT_REF_SLUG
# action: stop
# script:
# - echo Removing review https\://catalogui-${CI_COMMIT_REF_SLUG}.review.genesys\-pgr.org
# # Address the swarm
# - export DOCKER_HOST=swarm.genesys-pgr.org
# # Configuration
# - TLS_PATH=~/.docker/${DOCKER_HOST}/certs && mkdir -p ${TLS_PATH}
# - echo "${DOCKER_TLS_CA}" > ${TLS_PATH}/ca.pem
# - echo "${DOCKER_TLS_KEY}" > ${TLS_PATH}/key.pem
# - echo "${DOCKER_TLS_CERT}" > ${TLS_PATH}/cert.pem
# - export DOCKER_TLS_VERIFY=1
# - export DOCKER_CERT_PATH=${TLS_PATH}
# - DOCKER_CMD=docker
# # Actions
# - ${DOCKER_CMD} stack rm catalogui-${CI_COMMIT_REF_SLUG}-review
#
# deploy to production:
# stage: deploy
# image: docker:latest
# when: manual
# variables:
# GIT_STRATEGY: none
# script:
# - echo "Deploy to production server"
# # Address the swarm
# - export DOCKER_HOST=swarm.genesys-pgr.org
# # Configuration
# - TLS_PATH=~/.docker/${DOCKER_HOST}/certs && mkdir -p ${TLS_PATH}
# - echo "${DOCKER_TLS_CA}" > ${TLS_PATH}/ca.pem
# - echo "${DOCKER_TLS_KEY}" > ${TLS_PATH}/key.pem
# - echo "${DOCKER_TLS_CERT}" > ${TLS_PATH}/cert.pem
# - export DOCKER_TLS_VERIFY=1
# - export DOCKER_CERT_PATH=${TLS_PATH}
# - DOCKER_CMD=docker
# # Actions
# - ${DOCKER_CMD} service update --image ${CI_REGISTRY_IMAGE}:${IMAGE_VERSION} catalog_server
# only:
# - master
# environment:
# name: production
# url: https://catalog.genesys-pgr.org
......@@ -2,23 +2,27 @@
React application.
# Run with Docker
```bash
docker run -it \
-e CLIENT_ID=my-...-client \
-e CLIENT_SECRET=my-...-client \
-e CATALOG_API_URL=https://catalog-master.review.genesys-pgr.org \
dockerhub.croptrust.org/genesys-pgr/catalog/genesys-catalog-ui:1.0-latest
```
# Development
This project uses npm, gulp and webpack to package the React TypeScript application.
Before run, specify environment variables inside pom.xml file.
Optional params supported:
`defaultPort` - ui server port
`defaultHost` - ui server host
`CLIENT_SECRET` - ui app sicret used for oauth authentication in java server
`clientSicret` - ui app sicret used for oauth authentication in java server
`CLIENT_ID` - ui app id used for oauth authentication in java server
`clientId` - ui app id used for oauth authentication in java server
`apiUrl` - url to java server
`CATALOG_API_URL` - url to java server
`googleClientId` - id of google project, used for oauth authentication with google.
......@@ -27,11 +31,7 @@ Google api for configure projects: <https://console.developers.google.com>
To start a live-reload server and work on the application, run:
```bash
mvn install
```
or
```bash
mvn install -Denvironment=development
npm run server
```
This starts the _webpack-dev-server_ on port 3000:
......@@ -42,12 +42,13 @@ This starts the _webpack-dev-server_ on port 3000:
Pack the React application for production and test server-side loading (run express server):
```bash
mvn install -Denvironment=production
npm run server:production
```
Example of using optional params:
```bash
mvn install -DdefaultPort=3000 -DdefaultHost=0.0.0.0 -DclientSicret=sicret -DclientId=id -DapiUrl=http://localhost:8080 -DgoogleClientId=googleId
CLIENT_ID=client-id CLIENT_SECRET=client-secret CATALOG_API_URL=http://localhost:8080 npm run server
```
## Documentation
......@@ -60,4 +61,3 @@ We rely on the following libraries to make things work:
- React CSS modules: <https://github.com/gajus/react-css-modules#whats-the-problem>
- Immutability helpers: <https://github.com/kolodny/immutability-helper>
#
# Build Genesys Catalog UI server on top of node:alpine
#
FROM node:8.1-alpine
LABEL maintainer "Matija Obreza <matija.obreza@croptrust.org>"
ENV USER=nobody \
APP_PATH=/var/www/genesys-catalog-ui
# Entrypoint
COPY ssr.sh /
# Application
COPY www ${APP_PATH}/
# List image contents
RUN chmod +x /ssr.sh \
&& chmod go+r ${APP_PATH} \
&& find ${APP_PATH} -type f -exec ls -la {} \;
WORKDIR ${APP_PATH}
CMD [ "/ssr.sh" ]
#!/bin/sh
echo "Running Genesys Catalog UI from `pwd` with CLIENT_ID=${CLIENT_ID} and API at ${CATALOG_API_URL}"
echo "Starting on TCP port ${PORT}"
node index.js
......@@ -24,7 +24,9 @@
"build": "webpack --config config/webpack-development.config.js",
"server": "webpack-dev-server --config config/webpack-development.config.js",
"server:production": "cross-env NODE_ENV=production webpack-dev-server --config config/webpack-production.config.js",
"build:production": "cross-env NODE_ENV=production webpack --config config/webpack-production.config.js"
"build:production": "cross-env NODE_ENV=production webpack --config config/webpack-production.config.js",
"build:target": "gulp clean:all; gulp build:prod; cross-env NODE_ENV=production webpack --config config/webpack-production.config.js"
},
"reactToolbox": {
"output": "src/main/react/assets"
......
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