I am migrating to Jekyll, and in order to do that I am deploying my webpage in a completely continous deployment method. My current tool stack is as follows:
- Add code
- Commit and Push it
- Gitlab-CI picks up the change and starts the build process:
- build _site
- build docker container
- deploy updated container to openshift
Everything is completely hands off after I make a change in my code base.
It’s really slick. Here is my .gitlab-ci.yml:
image: ruby:2.4
stages:
- static
- build
- deploy
static-tests:
stage: static
artifacts:
paths:
- _site/
cache:
paths:
- _site/
script:
- bundle install
- bundle exec jekyll build
docker-image:
stage: build
image: docker:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN <registry>
- docker build -t <registry>/<image path>:latest .
- docker push <registry>/<image path>:latest
deploy:
image: widerin/openshift-cli
stage: deploy
script:
- oc login "$OPENSHIFT_SERVER" --insecure-skip-tls-verify --token="$OPENSHIFT_TOKEN"
- oc project <project>
- oc import-image <image path>:latest --from=<registry>/<image path>:latest --confirm
The dockerfile was also interesting, as I had to run nginx as a non-root user:
FROM nginx:1.13-alpine
COPY \_site /var/www/html
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
user nobody
It was pretty straightforward, but I got a little caught up dealing with getting openshift running and working. Now that everything is running I will be able to start developing some fun microservices and API’s.
Stay tuned for more!