Improvements #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
# This is used to complete the identity challenge | |
# with sigstore/fulcio when running outside of PRs. | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- run: | | |
docker build . -t "ghcr.io/${{ github.repository }}:hello-world-crac-checkpointer" --file crac/Dockerfile | |
docker run -d --cap-add CHECKPOINT_RESTORE --cap-add SYS_PTRACE --rm --name hello-world-crac-checkpointer "ghcr.io/${{ github.repository }}:hello-world-crac-checkpointer" | |
echo "Container ID: $(docker ps -qf "name=hello-world-crac-checkpointer")" | |
while logs=$(docker logs "$(docker ps -qf "name=hello-world-crac-checkpointer")" 2>&1); do | |
echo "$logs" | grep -q "Checkpoint creation succeeded" && echo "Checkpoint creation succeeded" && break | |
echo "$logs" | grep -q "Checkpoint creation failed" && echo "Checkpoint creation failed" && exit 1 | |
sleep 2 | |
done | |
docker commit --change='ENTRYPOINT ["/opt/app/entrypoint.sh"]' $(docker ps -qf "name=hello-world-crac-checkpointer") "ghcr.io/${{ github.repository }}:hello-world-crac" | |
docker kill $(docker ps -qf "name=hello-world-crac-checkpointer") | |
- uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: docker push ghcr.io/${{ github.repository }}:hello-world-crac | |