Prepare the infrastructure
Requirements
- 
            CI system; 
- 
            Linux host for running CI jobs, with: - 
                Shell Runner of your CI system of choice; 
- 
                Bash; 
- 
                Git version 2.18.0 or above; 
- 
                GPG; 
 
- 
                
Installing werf
To install werf, run the following command on the host for running CI jobs:
curl -sSL https://werf.io/install.sh | bash -s -- --ci
Configuring the container registry
Enable garbage collection for your container registry.
Preparing the system for cross-platform building (optional)
This step only needed to build images for platforms other than host platform running werf.
Register emulators on your system using qemu-user-static:
docker run --restart=always --name=qemu-user-static -d --privileged --entrypoint=/bin/sh multiarch/qemu-user-static -c "/register --reset -p yes && tail -f /dev/null"
Configure the project
Configuring CI/CD of the project
This is how the repository that uses werf for build and deploy might look:
.helm
app
pseudo-ci-cd-config.yaml
werf.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
        - name: app
          image: {{ .Values.werf.image.app }}
apiVersion: v1
kind: Service
metadata:
  name: app
spec:
  selector:
    app: app
  ports:
    - name: app
      port: 80
FROM node
WORKDIR /app
COPY . .
RUN npm ci
CMD ["node", "server.js"]
{
  "name": "app",
  "version": "1.0.0",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "name": "app",
      "version": "1.0.0"
    }
  }
}
{
  "name": "app",
  "version": "1.0.0",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  }
}
const http = require('http');
const hostname = '127.0.0.1';
const port = 80;
const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});
server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});
environment_variables:
  WERF_REPO: registry.example.org/myrepo
  WERF_ENV: "${CI_ENVIRONMENT}"
  WERF_ENABLE_PROCESS_EXTERMINATOR: "1"
before_every_job:
  - source "$(~/bin/trdl use werf 2 stable)"
  - werf cr login -u "${REGISTRY_USER:?}" -p "${REGISTRY_PASSWORD:?}" "${WERF_REPO:?}"
jobs:
  prod:
    commands:
      - werf converge
    environment: prod
    on: master
    how: manually
  images:cleanup:
    commands:
      - werf cleanup
    on: master
    how: daily
configVersion: 1
project: myproject
---
image: app
dockerfile: Dockerfile
context: ./app
Working with sources locally
            
          
        git clone https://github.com/werf/website
cp -rf website/examples/configurator/ci-cd/simple/other/host-runner/linux/docker example
cd example
git init
git add .
git commit -m-
Extras:
- Add authorization options for werf cleanupin the container registry by following instructions;
- See the authentication guide for more information on accessing the Kubernetes cluster.