Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to codespaces and remove gitpod support #69

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .devcontainer/cmake/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Jumpstart cmake/docmake",
"image": "ghcr.io/langchr86/docmake@sha256:32d37fb9a637f0bd2b7860305a31e29ceb665f5f8f884b463a1da4d74cbf308d",
"customizations": {
"vscode": {
"extensions": [
"anwar.papyrus-pdf",
"lvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cmake-tools",
"twxs.cmake"
]
}
}
}
17 changes: 17 additions & 0 deletions .devcontainer/java/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Jumpstart java",
"image": "mcr.microsoft.com/devcontainers/java:dev-17-jdk-bookworm",
"features": {
"ghcr.io/devcontainers-contrib/features/maven-sdkman": {
"jdkVersion": "17",
"jdkDistro": "tem"
}
},
"customizations": {
"vscode": {
"extensions": [
"redhat.java",
]
}
}
}
9 changes: 9 additions & 0 deletions .devcontainer/linux/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Jumpstart linux part",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"dockerDashComposeVersion": "v2"
}
}
}
152 changes: 152 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: "build images"
on:
workflow_dispatch:
workflow_call:
push:
paths:
- '.github/workflows/build-images.yml'
- '**/Dockerfile'
- 'docker-compose.yml'

env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1

jobs:
build-info:
runs-on: ubuntu-latest
outputs:
repo-owner: ${{ steps.repo-owner.outputs.result }}
tags: ${{ steps.image-tags.outputs.image-tags }}
build-config: ${{ steps.build-info.outputs.result }}
steps:

#github forces lower case for the image name
- name: Get lowercase repo owner name
uses: actions/github-script@v7
id: repo-owner
with:
result-encoding: string
script: |
return context.repo.owner.toLowerCase()

- uses: actions/checkout@v4

- name: Set nightly tag if commit was on main
id: add-nightly-tag
if: startsWith(github.ref, 'refs/heads/main')
run: |
echo "nightly-tag=nightly" | tr -d "\n" >> $GITHUB_OUTPUT

- name: Set latest tag if its a tag
id: add-latest-tag
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "latest-tag=latest" | tr -d "\n" >> $GITHUB_OUTPUT

- uses: actions/github-script@v7
id: get-tag
if: startsWith(github.ref, 'refs/tags/')
with:
result-encoding: string
script: |
return context.payload.ref.replace('refs/tags/', '')

- name: concat tags to list
id: image-tags
run: |
TAGS=$(cat <<-END
[
"${{ github.sha }}",
"${{ steps.add-nightly-tag.outputs.nightly-tag }}",
"${{ steps.add-latest-tag.outputs.latest-tag }}",
"${{ steps.get-tag.outputs.result }}"
]
END
)
TAGS=$(echo $TAGS | jq -c 'map(select(length > 0))')
echo "image-tags=$TAGS" | tr -d "\n" >> $GITHUB_OUTPUT

- name: Get build info
id: build-info
run: |
set -x
sudo snap install yq

compose_paths=""
for i in $(find . -name docker-compose.yml); do
compose_paths="$compose_paths -f $i"
done

docker compose $compose_paths config > /tmp/docker-compose.yml
yq_pipe='.services.[]'
yq_pipe=$yq_pipe'| select(.build != null)'
yq_pipe=$yq_pipe'| [.build * {"image": .image}]'
yq_pipe=$yq_pipe'| map(.dockerfile=.context + "/" + .dockerfile)'
BUILD_INFO=$(cat /tmp/docker-compose.yml | yq "$yq_pipe" -o=json)
BUILD_INFO=$(echo $BUILD_INFO | jq -c -s add | sed "s|:local||g")
echo "result=$BUILD_INFO" | tr -d "\n" >> $GITHUB_OUTPUT
env:
REPO_OWNER: ${{ steps.repo-owner.outputs.result }}
VERSION: local

build-image:
runs-on: ubuntu-latest
needs:
- build-info
strategy:
fail-fast: false
matrix:
build-config: ${{ fromJSON(needs.build-info.outputs.build-config) }}
env:
tags: ${{ needs.build-info.outputs.tags }}
repo-owner: ${{ needs.build-info.outputs.repo-owner }}
steps:
- uses: actions/checkout@v4

- run: |
echo "inputs:"
cat <<-HEREDOC
${{ toJSON(inputs) }}
HEREDOC

echo "build config:"
cat <<-HEREDOC
${{ toJSON(matrix.build-config) }}
HEREDOC

echo "build tags:"
cat <<-HEREDOC
${{ env.tags }}
HEREDOC

echo "build repo owner:"
cat <<-HEREDOC
${{ env.repo-owner }}
HEREDOC

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

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

- uses: actions/github-script@v7
id: expand-tags
with:
script: |
return JSON.parse('${{ env.tags }}').map(tag => `${{ matrix.build-config.image }}:${ tag }`)

- name: Build and push image
uses: docker/build-push-action@v5
with:
push: true
file: ${{ matrix.build-config.dockerfile }}
tags: ${{ join(fromJSON(steps.expand-tags.outputs.result)) }}
context: ${{ matrix.build-config.context }}
cache-from: type=gha,scope=${{ matrix.build-config.image }}
cache-to: type=gha,scope=${{ matrix.build-config.image }},mode=max
37 changes: 0 additions & 37 deletions .github/workflows/gitpod-image.yml

This file was deleted.

1 change: 0 additions & 1 deletion gitpod/.dockerignore

This file was deleted.

32 changes: 0 additions & 32 deletions gitpod/Dockerfile

This file was deleted.

9 changes: 9 additions & 0 deletions topics/linux/code/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM registry.fedoraproject.org/fedora:39

RUN dnf install -y \
systemd \
bash \
vim \
&& dnf clean all

CMD [ "/usr/sbin/init" ]
8 changes: 8 additions & 0 deletions topics/linux/code/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
systemd:
image: ${REGISTRY:-ghcr.io}/${REPO_OWNER:-scs}/jumpstart-docs/fedora-systemd:${VERSION:-latest}
build: container
volumes:
- ./hello_world_service:/hello_world_service/hello_world_service
- ./solution:/hello_world_service/solution
privileged: true
4 changes: 2 additions & 2 deletions topics/linux/code/solution/update-hello-world-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SCRIPT_DIR=$(dirname $(realpath $0))

hello_world_versions_dir=$(realpath $SCRIPT_DIR/../hello_world_service)
last_file=$(ls -t $hello_world_versions_dir | head -1)
sudo service hello-world stop
sudo systemctl stop hello-world
sudo cp $hello_world_versions_dir/$last_file /usr/local/bin/hello-world
sudo chmod +x /usr/local/bin/hello-world
sudo service hello-world start
sudo systemctl start hello-world
13 changes: 12 additions & 1 deletion topics/linux/linux_exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ Jetzt möchten wir, dass das hello-world Skript beim Aufstarten automatisch gest
und die Meldungen ins journald schreibt.
Nutze für diese Übung vim.

In Github Codespaces steht nicht direkt systemd zur Verfügung.
Deshalb ist ein Container image vorbereitet, in dem wir systemd zur Verfügung haben.
Führe deshalb folgende Befehle im ausgecheckten git repo auf Github Codespaces aus:

```shell
cd topics/linux/code
docker compose up -d
docker compose exec -it systemd bash
```

1. Erstelle deine Service Konfiguration in /etc/systemd/system/hello-world.service
1. Starte den Service nach systemd-user-sessions.service
1. Vergiss nicht den Service zu enablen
Expand All @@ -128,7 +138,8 @@ Nutze für diese Übung vim.
1. Passe das update Script so an, dass es den Service vor dem Update des Skripts stoppt, und danach wieder startet.
1. Teste mit journald, was der hello-world service ausgibt.
1. Stoppe den service. Werden keine neuen Meldungen mehr ins journald geschrieben?
1. Starte die VM neu, startet der Service auch neu?
1. Starte den Container (von ausserhalb des containers) mit `docker compose restart systemd` neu.
Startet der Service auch neu?
1. Disable den Service nach dem Ende der Übung, du willst dein Log nicht füllen.

<#ifdef solution>
Expand Down
3 changes: 0 additions & 3 deletions topics/testing/testing_exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ title: "Arbeitsblatt: Testing"
Testing
===================================

For a no effort setup (just github account needed), you can use Gitpod with a vscode editor in the browser.
[https://gitpod.io/#https://github.com/scs/jumpstart-docs](https://gitpod.io/#https://github.com/scs/jumpstart-docs)

Leap Year
--------

Expand Down
Loading