Gitlab ci this blog

Author Photo

Mikael Eklund

· 1 min read

With a blog up and running I decided that it was time to try to deploy it to an okd cluster through ci/cd. okd is the open source version of ocp or Openshift that we use at work. The first step will be having Gitlab creating the docker image when the repo gets updated.

Create Runner

On the admin page choose runners and follow the instructions to create a shared one. I choose anothter server to host the runners

I had some issues with dns in the runners and some issues with the runners. All of these issues where solved by editing the etc/gitlab-runner/config.toml file. Under [runners.docker] i altered or added: privileged = true volumes = [“/cache”,“/certs/client”] extra_hosts = [“”]

extra_hosts is like adding a entry in the /etc/hosts file on a Linux server.

# stage build
FROM node:16-alpine


# copy everything to the container
COPY . .

# install everything to the container
RUN npm install

# build SvelteKit app
RUN npm run build

# stage run
FROM node:16-alpine


# copy dependency list
COPY --from=0 /app/package*.json ./

# copy built SvelteKit app to /app
COPY --from=0 /app/build ./

CMD ["node", "./index.js"]

The script above builds our Svelekit application. The next step is to let the Gitlab pipelines create the docker image. my image With that on place we have a working ci part. When pushing new code to our Gitlab server we will build a new docker image with the latest code on it.

Author Photo

About Mikael Eklund

Mikael Eklund is a Senior it technology specialist. With a passion for technology and programming.