Skip to content

Commit

Permalink
repo reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrtak-CZ committed Jul 6, 2023
1 parent 48bb05a commit d7795c6
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 112 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github
README.md
LICENSE.md
Dockerfile
.editorconfig
.gitignore
testing.sh
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 200
tab_width = 2
139 changes: 139 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Container Image
on:
push:
branches:
- 'main'
tags:
- '**'

env:
kubectl_version: 1.27.3
helm_version: 3.12.1
sentry_cli_version: 2.19.4
aws_cli_version: 2.12.7

jobs:
build:
name: Build container image and push it to registry
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
id-token: write
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1

- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public

- name: Parse version
id: get-version
uses: battila7/get-version-action@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push - testing - slim
uses: docker/build-push-action@v3
timeout-minutes: 15
if: ${{ !steps.get-version.outputs.is-semver }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
KUBECTL_VERSION=${{ env.kubectl_version }}
HELM_VERSION=${{ env.helm_version }}
SENTRY_CLI_VERSION=${{ env.sentry_cli_version }}
AWS_CLI_VERSION=${{ env.aws_cli_version }}
tags: |
cookielab/deployer:${{ github.ref_name }}-slim
public.ecr.aws/cookielab/deployer:${{ github.ref_name }}-slim
ghcr.io/${{ github.repository }}:${{ github.ref_name }}-slim
- name: Build and push - pre-release - slim
uses: docker/build-push-action@v3
timeout-minutes: 15
if: ${{ steps.get-version.outputs.is-semver && steps.get-version.outputs.prerelease != '' }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
KUBECTL_VERSION=${{ env.kubectl_version }}
HELM_VERSION=${{ env.helm_version }}
SENTRY_CLI_VERSION=${{ env.sentry_cli_version }}
AWS_CLI_VERSION=${{ env.aws_cli_version }}
tags: |
cookielab/deployer:${{ steps.get-version.outputs.version-without-v }}-slim
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.version-without-v }}-slim
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.version-without-v }}-slim
- name: Build and push - stable - slim
uses: docker/build-push-action@v3
timeout-minutes: 15
if: ${{ steps.get-version.outputs.is-semver && steps.get-version.outputs.prerelease == '' }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
KUBECTL_VERSION=${{ env.kubectl_version }}
HELM_VERSION=${{ env.helm_version }}
SENTRY_CLI_VERSION=${{ env.sentry_cli_version }}
AWS_CLI_VERSION=${{ env.aws_cli_version }}
tags: |
cookielab/deployer:${{ steps.get-version.outputs.version-without-v }}-slim
cookielab/deployer:${{ steps.get-version.outputs.version-without-v }}
cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}-slim
cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}
cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}-slim
cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}
cookielab/deployer:${{ steps.get-version.outputs.major }}-slim
cookielab/deployer:${{ steps.get-version.outputs.major }}
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.version-without-v }}-slim
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.version-without-v }}
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}-slim
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}-slim
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.major }}-slim
public.ecr.aws/cookielab/deployer:${{ steps.get-version.outputs.major }}
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.version-without-v }}-slim
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.version-without-v }}
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}-slim
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}-slim
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.major }}-slim
ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.major }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testing.sh
34 changes: 0 additions & 34 deletions .gitlab-ci.yml

This file was deleted.

65 changes: 34 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
FROM cookielab/alpine:3.13
FROM cookielab/slim:12.0 AS build

ARG TARGETARCH
WORKDIR /tmp

RUN apt update && apt install -y curl zip

ARG KUBECTL_VERSION
RUN curl -L "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl" -o /usr/local/kubectl
RUN chmod +x /usr/local/kubectl

ARG KUBE_VERSION
ARG HELM_VERSION
ARG SENTRY_CLI_VERSION
ARG KUBEDOG_VERSION
ARG KAIL_VERSION

ADD kube-connect /usr/local/bin/kube-connect

RUN apk --update --no-cache add ca-certificates openssh bash curl gzip unzip git jq gettext
RUN chmod +x /usr/local/bin/kube-connect
RUN curl -L https://storage.googleapis.com/kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl
RUN curl -L https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz -o ./helm.tar.gz
RUN tar -xzf ./helm.tar.gz
RUN rm ./helm.tar.gz
RUN mv ./linux-amd64/helm /usr/local/bin/helm
RUN curl -L "https://get.helm.sh/helm-v${HELM_VERSION}-linux-${TARGETARCH}.tar.gz" -o /tmp/helm.tar.gz
RUN tar -xzf /tmp/helm.tar.gz
RUN rm /tmp/helm.tar.gz
RUN mv /tmp/linux-${TARGETARCH}/helm /usr/local/bin/helm
RUN chmod +x /usr/local/bin/helm
RUN rm -rf ./linux-amd64
RUN curl -L https://downloads.sentry-cdn.com/sentry-cli/${SENTRY_CLI_VERSION}/sentry-cli-Linux-x86_64 -o ./sentry-cli
RUN mv ./sentry-cli /usr/local/bin/sentry-cli
RUN chmod +x /usr/local/bin/sentry-cli
RUN curl -L https://tuf.kubedog.werf.io/targets/releases/${KUBEDOG_VERSION}/linux-amd64/bin/kubedog -o /usr/local/bin/kubedog
RUN chmod +x /usr/local/bin/kubedog
RUN curl -L https://github.com/boz/kail/releases/download/v${KAIL_VERSION}/kail_${KAIL_VERSION}_linux_amd64.tar.gz -o /tmp/kail.tar.gz && \
tar xvzf /tmp/kail.tar.gz && \
mv kail /usr/local/bin/ && \
rm -rf /tmp/*
RUN chmod +x /usr/local/bin/kail

USER 1987
ARG SENTRY_CLI_VERSION
RUN curl -sL https://sentry.io/get-cli/ | INSTALL_DIR="/usr/local/bin" sh

ARG AWS_CLI_VERSION
COPY download-aws-cli.sh /tmp/download-aws-cli.sh
RUN /tmp/download-aws-cli.sh

RUN mkdir -p -m 0700 /container/.ssh
RUN touch /container/.ssh/known_hosts
RUN chmod 0644 /container/.ssh/known_hosts
FROM cookielab/slim:12.0

RUN apt update && apt install -y curl jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=build /usr/local/bin /usr/local/bin

COPY --from=build /tmp/aws /tmp/aws
RUN /tmp/aws/install
RUN rm -rf /tmp/aws

ARG GITHUB_TOKEN

USER 1987

ONBUILD USER root
34 changes: 2 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
# Cookielab - Deployer image
# cookielab/deployer

This image is based on [our Alpine Linux image](https://cloud.docker.com/u/cookielab/repository/docker/cookielab/alpine).

We make this image for deploying our applications from Gitlab to Kubernetes.

This image contains [`kubectl`](https://kubernetes.io/docs/reference/kubectl/overview/), [`terraform`](https://terraform.io), [`helm`](https://helm.sh/), [`sentry-cli`](https://docs.sentry.io/cli/) and [`kubeless`](https://kubeless.io/).
It also contains `kube-connect` script with will connect to your kubernetes cluser via env variables (standard one in Gitlab CI).

## Usage

```bash
# kubectl
docker run --rm cookielab/deployer:0.11
> kube-connect
> kubectl version

# terraform
docker run --rm cookielab/deployer:0.11 terraform version

# helm
docker run --rm cookielab/deployer:0.11
> kube-connect
> helm version

# sentry-cli
docker run --rm cookielab/deployer:0.11 sentry-cli --version

# kubeless
docker run --rm cookielab/deployer:0.11
> kube-connect
> kubeless version
```
@todo
9 changes: 0 additions & 9 deletions UPDATING.md

This file was deleted.

8 changes: 8 additions & 0 deletions download-aws-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -xe

TARGETARCH_ALT=$(echo "${TARGETARCH}" | sed s/arm64/aarch64/ | sed s/amd64/x86_64/)

curl -L "https://awscli.amazonaws.com/awscli-exe-linux-${TARGETARCH_ALT}-${AWS_CLI_VERSION}.zip" -o /tmp/awscliv2.zip
unzip /tmp/awscliv2.zip
6 changes: 0 additions & 6 deletions kube-connect

This file was deleted.

0 comments on commit d7795c6

Please sign in to comment.