Skip to content

Commit

Permalink
build: Change docker image, enable server build (#2716)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolajb authored Oct 10, 2024
1 parent 9720a8b commit b557632
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 27 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ updates:
- "dependencies"
- "ok-to-test"
- "ready-for-review"

- package-ecosystem: "docker"
directory: "/server/"
schedule:
interval: "weekly"
day: "sunday"
time: "10:00"
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GIT_TAG: ${{ env.GIT_TAG }}
run: devbox run -- just release-oci

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Release kommander applications server
env:
GIT_TAG: ${{ env.GIT_TAG }}
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
devbox run -- just release-server
5 changes: 4 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ jobs:
git diff --exit-code
- name: Check if kommander application server works
run: devbox run -- just test-server
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
devbox run -- just test-server
- name: Report Coveralls
uses: coverallsapp/github-action@v2
Expand Down
1 change: 1 addition & 0 deletions .include-airgapped
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./clusters
./common
./services
./charts
20 changes: 11 additions & 9 deletions just/test.just
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
test-server:
#!/usr/bin/env bash
set -euox pipefail
CONTAINER_ID=$(just --justfile {{ justfile() }} --working-directory {{ invocation_directory() }} _run_server 2>&1 | tail -n 1)
trap "docker kill ${CONTAINER_ID}" EXIT
curl --no-progress-meter --output /dev/null --retry-connrefused --retry 5 --retry-delay 3 http://localhost:5000/{{ archive_name }}
test_container_name := "kommander-applications-server"

test-server: _run_server
sleep 3 # wait for container
git ls-remote git://localhost:12345/data

_run_server: (release-server "false")
docker run \
--env DUFS_TLS_CERT \
--env DUFS_TLS_KEY \
--network=host \
--name {{ test_container_name }} \
--publish 12345:12345 \
--detach \
--user 1000:1000 \
{{ server_docker_repository }}:{{ git_tag }}

_kill_server:
docker kill {{ test_container_name }}
34 changes: 26 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@ archive_name := "kommander-applications-" + git_tag+ ".tar.gz"
published_url := "https://downloads.d2iq.com" / s3_path / archive_name

release publish="true" tmp_dir=`mktemp --directory`: (_prepare-archive tmp_dir) && _cleanup
if {{ publish }}; then aws s3 cp --acl {{ s3_acl }} {{ archive_name }} {{ s3_uri }}; fi
@echo "Published to {{ published_url }}"
#!/usr/bin/env bash
set -euox pipefail
if {{ publish }}; then
aws s3 cp --acl {{ s3_acl }} {{ archive_name }} {{ s3_uri }}
echo "Published to {{ published_url }}"
else
echo "Skipping publish"
fi
release-oci publish="true" tmp_dir=`mktemp --directory`: (_prepare-files-for-a-bundle tmp_dir)
if {{ publish }}; then \
cd {{ tmp_dir }} && echo "${DOCKER_PASSWORD}" | oras push --password-stdin --username "${DOCKER_USERNAME}" --verbose {{ registry }}/{{ repository }}:{{ git_tag }} .;
#!/usr/bin/env bash
set -euox pipefail
cd {{ tmp_dir }}
if {{ publish }}; then
oras push --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" --verbose {{ registry }}/{{ repository }}:{{ git_tag }} .
else
echo "Skipping publish"
fi
release-server publish="true" tmp_dir=`mktemp --directory`: (_prepare-archive tmp_dir) && _cleanup
cp {{ archive_name }} ./server/
cd ./server && docker buildx build . --tag {{ server_docker_repository }}:{{ git_tag }} --build-arg ARCHIVE_NAME={{ archive_name }}
rm ./server/{{ archive_name }}
release-server publish="true" tmp_dir=`mktemp --directory`: (_prepare-git-repository tmp_dir)
cp -r {{ tmp_dir }} ./server/data/
cd ./server && docker buildx build . --tag {{ server_docker_repository }}:{{ git_tag }}
rm -rf ./server/data/
if {{ publish }}; then docker push {{ server_docker_repository }}:{{ git_tag }}; fi

service_version:=`ls services/git-operator/ | grep -E "v?[[:digit:]]\.[[:digit:]]\.[[:digit:]]"`
Expand All @@ -44,11 +55,18 @@ git-operator-fetch-manifests tmp_dir=`mktemp --directory`:
_prepare-archive dir: (_prepare-files-for-a-bundle dir)
tar -cvzf {{ justfile_directory() }}/{{ archive_name }} -C {{ dir }} .

_prepare-git-repository output_dir tmp_dir_for_cloning=`mktemp --directory`:
cd {{ output_dir }} && git init --bare --initial-branch=main
git clone {{ output_dir }} {{ tmp_dir_for_cloning }}
just --justfile {{ justfile() }} --working-directory {{ invocation_directory() }} _prepare-files-for-a-bundle {{ tmp_dir_for_cloning }}
cd {{ tmp_dir_for_cloning }} && git add . && git commit --no-gpg-sign --message "initial commit" && git push origin main

_cleanup:
rm {{ archive_name }}

_prepare-files-for-a-bundle output_dir:
rsync --quiet --archive --recursive --files-from={{ include_file }} --exclude-from={{ exclude_file }} {{ justfile_directory() }} {{ output_dir }}
yq 'del(.resources[] | select(. == "ai-navigator-repos.yaml"))' --inplace {{ output_dir }}/common/helm-repositories/kustomization.yaml


import 'just/test.just'
16 changes: 7 additions & 9 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
FROM sigoden/dufs
FROM alpine:3.20.3

ARG ARCHIVE_NAME
LABEL org.opencontainers.image.source=https://github.com/alpinelinux/docker-alpine

# Dufs settings:
ENV DUFS_BIND=127.0.0.1
ENV DUFS_PORT=5000
ENV DUFS_TLS_CERT=cert.pem
ENV DUFS_TLS_KEY=key.pem
RUN apk add --update git && \
apk add --update git-daemon \
rm -rf /var/cache/apk/*

COPY ${ARCHIVE_NAME} /data/
COPY --chown=1000:1000 data /data

CMD ["/data"]
CMD ["git", "daemon", "--verbose", "--port=12345","--export-all", "/data"]

0 comments on commit b557632

Please sign in to comment.