Commit 4bdb8b7c authored by Jo's avatar Jo
Browse files

feat(ci-runner): first draft

parent 57f65303
COMPOSE_PROJECT_NAME=socialgouv_docker_ci-runner
ARG UBUNTU_VERSION=latest
ARG GOMPLATE_VERSION=v3.6.0-slim
FROM hairyhenderson/gomplate:$GOMPLATE_VERSION as gomplate
FROM ubuntu:$UBUNTU_VERSION
ARG NODE_VERSION=16
ARG KUBECTL_VERSION=1.20.1
ARG KUSTOMIZE_VERSION=3.5.2
ARG HELM_VERSION=3.4.2
# install gomplate
COPY --from=gomplate /gomplate /usr/local/bin/gomplate
# install dependencies
RUN apt-get update -yq && \
apt-get -y install \
curl \
wget \
gnupg \
bash \
jq \
sed \
grep \
git \
unzip \
postgresql-client
# install kubectl
RUN wget -q -O /dev/shm/kubectl \
"https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
&& chmod +x /dev/shm/kubectl \
&& mv /dev/shm/kubectl /usr/local/bin/kubectl
# install kustomize
RUN wget -q -O /dev/shm/kustomize.tar \
"https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz" \
&& tar xvzf /dev/shm/kustomize.tar \
&& mv /kustomize /usr/local/bin/kustomize
# install helm
RUN wget -q -O /dev/shm/helm.tar.gz \
"https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz" \
&& tar xvzf /dev/shm/helm.tar.gz \
&& mv /linux-amd64/helm /usr/local/bin/helm
# install nodejs
RUN apt-get update -yq && \
curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
apt-get -y install nodejs
# install deno
RUN curl -fsSL https://deno.land/x/install/install.sh | sh
USER 1000
ENTRYPOINT [ "/bin/sh", "-c" ]
CMD []
#
DOCKER_COMPOSE = docker-compose
all: test build lint
lint:
$(DOCKER_COMPOSE) run --rm lint
build: lint
$(DOCKER_COMPOSE) build
test: build test_structure
test_structure:
$(DOCKER_COMPOSE) run --rm test
# ci-runner
> Generic toolbox for CI runner, for example on github action
## Use it in github actions
```yaml
jobs:
my-cool-job:
name: The Cool Job
runs-on: ghcr.io/socialgouv/docker/ci-runner
steps:
- name: Apply manifest
run: kubectl apply -f ${{ github.action_path }}
```
```sh
$ docker run --rm ghcr.io/socialgouv/docker/ci-runner
```
services:
alpine:
build:
context: .
deploy:
replicas: 0
#
lint:
image: ghcr.io/hadolint/hadolint:v2.8.0-alpine
entrypoint: hadolint
command: Dockerfile
volumes:
- .:/home/socialgouv
working_dir: /home/socialgouv
test:
image: gcr.io/gcp-runtimes/container-structure-test:v1.11.0
depends_on:
alpine:
condition: service_started
command: >
test
--config tests/container-structure-test.yml
--image ${COMPOSE_PROJECT_NAME}_alpine
-v debug
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- .:/home/socialgouv
working_dir: /home/socialgouv
schemaVersion: "2.0.0"
metadataTest:
entrypoint: ["sh", "-c"]
commandTests:
- name: "kubectl version"
command: "kubectl"
args: ["version"]
expectedOutput: ["Client Version: version.Info{Major:\"1\".*"]
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