Skip to content

Commit

Permalink
Split image into devcontainer and jenkins-agent-dind
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Mar 13, 2024
1 parent 85f5f2b commit 251f4da
Show file tree
Hide file tree
Showing 46 changed files with 822 additions and 461 deletions.
7 changes: 3 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"build": {
"context": "..",
"dockerfile": "../Dockerfile"
"context": "../devcontainer",
"dockerfile": "../devcontainer/Dockerfile"
},
"overrideCommand": false,
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"runArgs": ["--network=host"],
"postCreateCommand": "pkgx install hadolint k3d helmfile werf kubectl",
"postCreateCommand": [".devcontainer/post_create.sh"],
"customizations": {
"vscode": {
"extensions": [
Expand Down
11 changes: 11 additions & 0 deletions .devcontainer/post_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -ex

pkgx install k3d@5 [email protected] werf@1 kubectl@1

if [[ "${CI:-false}" == false ]]; then
pkgx install npm@10 node@20 hadolint@2 [email protected]
fi

npm install --global @devcontainers/[email protected]
67 changes: 46 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,50 @@ name: ci

on:
push:
branches: [master]
branches:
- master
pull_request:
branches: [master]
branches:
- master
merge_group:

jobs:
build-and-push:
ci:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: docker_meta
- name: Docker meta (devcontainer)
id: docker-meta-devcontainer
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/devcontainer
flavor: |
latest=false
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,enable=${{ github.event_name == 'push' }}
type=raw,value=2,enable=${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,value=latest,enable=${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
- name: Docker meta (jenkins-agent-dind)
id: docker-meta-jenkins-agent-dind
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/jenkins-agent-dind
flavor: |
latest=false
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
type=sha,enable=${{ github.event_name == 'push' }}
type=raw,value=2,enable=${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,value=latest,enable=${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -40,28 +60,33 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup test dependencies
- name: Install pkgx
uses: pkgxdev/setup@v2
with:
+: k3d helmfile werf kubectl

- name: Install test dependencies
run: .devcontainer/post_create.sh

- name: Build
uses: docker/build-push-action@v5
uses: docker/bake-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
files: |
./docker-bake.hcl
${{ steps.docker-meta-devcontainer.outputs.bake-file }}
${{ steps.docker-meta-jenkins-agent-dind.outputs.bake-file }}
set: |
*.platform=linux/amd64,linux/arm64
- name: Test
run: |
tests/run.sh
./test.sh
- name: Push
uses: docker/build-push-action@v5
uses: docker/bake-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
files: |
./docker-bake.hcl
${{ steps.docker-meta-devcontainer.outputs.bake-file }}
${{ steps.docker-meta-jenkins-agent-dind.outputs.bake-file }}
set: |
*.platform=linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Felipe Santos
Copyright (c) 2024 Felipe Santos

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 251f4da

Please sign in to comment.