Skip to content

Commit

Permalink
feat(ci-runner): first draft (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Jan 14, 2022
1 parent 57f6530 commit 5a3cbb1
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions ci-runner/.env
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=socialgouv_docker_ci-runner
57 changes: 57 additions & 0 deletions ci-runner/Dockerfile
@@ -0,0 +1,57 @@
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 []
17 changes: 17 additions & 0 deletions ci-runner/Makefile
@@ -0,0 +1,17 @@
#

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

19 changes: 19 additions & 0 deletions ci-runner/README.md
@@ -0,0 +1,19 @@
# 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
```
31 changes: 31 additions & 0 deletions ci-runner/docker-compose.yml
@@ -0,0 +1,31 @@
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
10 changes: 10 additions & 0 deletions ci-runner/tests/container-structure-test.yml
@@ -0,0 +1,10 @@
schemaVersion: "2.0.0"

metadataTest:
entrypoint: ["sh", "-c"]

commandTests:
- name: "kubectl version"
command: "kubectl"
args: ["version"]
expectedOutput: ["Client Version: version.Info{Major:\"1\".*"]

0 comments on commit 5a3cbb1

Please sign in to comment.