Skip to content

Commit d747cf8

Browse files
authored
Merge pull request #8 from code0-tech/setup-first-builds
Setup first image builds
2 parents e5e859c + cd64c3d commit d747cf8

File tree

9 files changed

+182
-0
lines changed

9 files changed

+182
-0
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
pull-requests: write
11+
packages: write
12+
13+
jobs:
14+
pipeline:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: Taucher2003/GitLab-Pipeline-Action@1.10.1
18+
name: Run pipeline
19+
id: pipeline
20+
with:
21+
GL_SERVER_URL: https://gitlab.com
22+
GL_PROJECT_ID: '70259564'
23+
GL_RUNNER_TOKEN: ${{ secrets.GL_RUNNER_TOKEN }}
24+
GL_API_TOKEN: ${{ secrets.GL_API_TOKEN }}
25+
SHOW_JOB_LOGS: all
26+
OVERRIDE_GITHUB_SHA: ${{ github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }}
27+
OVERRIDE_GITHUB_REF_NAME: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.head.ref }}
28+
env:
29+
GLPA_C0_GH_REF: ${{ github.ref }}
30+
GLPA_C0_GH_REF_NAME: ${{ github.ref_name }}
31+
GLPA_C0_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Find existing comment
34+
uses: peter-evans/find-comment@v3
35+
id: find-comment
36+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
37+
with:
38+
issue-number: ${{ github.event.pull_request.number }}
39+
comment-author: 'github-actions[bot]'
40+
body-includes: <!-- glpa_comment:pipeline -->
41+
42+
- name: Create or update comment
43+
uses: peter-evans/create-or-update-comment@v4
44+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
45+
with:
46+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
47+
issue-number: ${{ github.event.pull_request.number }}
48+
body: |
49+
<!-- glpa_comment:pipeline -->
50+
${{ steps.pipeline.outputs.SUMMARY_TEXT }}
51+
edit-mode: replace

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea/
2+
*.iml
3+
4+
# generated dockerfiles
5+
container/sagittarius/Dockerfile
6+
7+
# downloaded projects
8+
projects

.gitlab-ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
stages:
2+
- container
3+
4+
.dind:
5+
variables:
6+
DOCKER_MIRROR: https://mirror.gcr.io
7+
DOCKER_OPTIONS: "--registry-mirror ${DOCKER_MIRROR}"
8+
DOCKER_DRIVER: overlay2
9+
DOCKER_HOST: tcp://docker:2376
10+
DOCKER_TLS_CERTDIR: /certs
11+
services:
12+
- name: docker:28.1.1-dind
13+
alias: docker
14+
entrypoint: [ "sh", "-c", "dockerd-entrypoint.sh $DOCKER_OPTIONS" ]
15+
16+
.image-build-base:
17+
extends:
18+
- .dind
19+
image: docker:28.1.1
20+
stage: container
21+
script:
22+
- apk add bash curl tar
23+
- source scripts/helpers.sh
24+
- docker_login
25+
- 'image=$(echo $CI_JOB_NAME | cut -d : -f 2)'
26+
- '[ -z "$NEED_PROJECT_DOWNLOAD" ] || download_project $image'
27+
- build_image $image $CI_PIPELINE_ID
28+
- push_image $image $CI_PIPELINE_ID
29+
30+
container:mise:
31+
extends:
32+
- .image-build-base
33+
34+
container:rust:
35+
extends:
36+
- .image-build-base
37+
needs:
38+
- container:mise
39+
40+
container:aquila:
41+
extends:
42+
- .image-build-base
43+
needs:
44+
- container:rust
45+
variables:
46+
NEED_PROJECT_DOWNLOAD: 'true'

container/aquila/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ARG RETICULUM_IMAGE_TAG=local
2+
3+
FROM ghcr.io/code0-tech/reticulum/ci-builds/rust:$RETICULUM_IMAGE_TAG as builder
4+
5+
WORKDIR /aquila
6+
COPY projects/aquila .
7+
RUN cargo build --release
8+
9+
FROM alpine:3.21
10+
11+
RUN apk --update add libc6-compat
12+
COPY --from=builder /aquila/target/release/aquila .
13+
14+
CMD ["/aquila"]

container/mise/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM alpine:3.21
2+
LABEL org.opencontainers.image.source=https://github.com/code0-tech/reticulum
3+
4+
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
5+
RUN apk add bash curl tar
6+
RUN apk add mise@edge

container/rust/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ARG RETICULUM_IMAGE_TAG=local
2+
3+
FROM ghcr.io/code0-tech/reticulum/ci-builds/mise:$RETICULUM_IMAGE_TAG
4+
5+
ARG RUST_VERSION=1.86
6+
7+
RUN apk add build-base
8+
RUN mise install-into rust@$RUST_VERSION /usr/local/share/rust
9+
ENV PATH=/usr/local/share/rust:$PATH

scripts/download_projects

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source scripts/helpers.sh
6+
7+
rm -rf projects
8+
mkdir projects
9+
10+
download_project aquila
11+
download_project sagittarius

scripts/helpers.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function download_project() {
2+
project=$1
3+
version=$(cat versions/$project)
4+
echo "Downloading $project at $version"
5+
mkdir -p projects
6+
curl --output projects/$project.tar.gz -L "https://github.com/code0-tech/$project/archive/$version.tar.gz" || return 1
7+
tar -xzf projects/$project.tar.gz -C projects || return 1
8+
rm projects/$project.tar.gz || return 1
9+
mv projects/$project-* projects/$project || return 1
10+
}
11+
12+
function docker_login() {
13+
echo $C0_GH_TOKEN | docker login -u $ --password-stdin ghcr.io
14+
}
15+
16+
function build_image() {
17+
image=$1
18+
reticulum_tag=$2
19+
20+
echo "Building image for $image"
21+
22+
if [ -x "container/$image/renderDockerfile" ]; then
23+
echo "Rendering Dockerfile for $image"
24+
container/$image/renderDockerfile
25+
fi
26+
27+
docker build \
28+
-t "ghcr.io/code0-tech/reticulum/ci-builds/$image:$reticulum_tag" \
29+
-f "container/$image/Dockerfile" \
30+
--build-arg RETICULUM_IMAGE_TAG=$reticulum_tag \
31+
.
32+
}
33+
34+
function push_image() {
35+
docker push "ghcr.io/code0-tech/reticulum/ci-builds/$image:$reticulum_tag"
36+
}

versions/aquila

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cf34c440f48a01b562787dcf716c354c5ba706a1

0 commit comments

Comments
 (0)