Test exercises #117
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
# 2024-05-02 10:50 | |
name: Test exercises | |
on: | |
push: ~ | |
schedule: | |
- cron: '30 10 * * 1' | |
jobs: | |
Test-exercise-1: | |
runs-on: ubuntu-latest | |
steps: | |
- run: docker run hello-world | |
- run: docker run python:alpine python --version | |
- run: docker run ubuntu ls | |
- name: Validate mongo:latest still exists | |
run: curl --silent -f --head -lL https://hub.docker.com/v2/repositories/library/mongo/tags/latest/ | |
Test-exercise-2: | |
runs-on: ubuntu-latest | |
steps: | |
- name: alpine:latest still has sh shell | |
run: docker run alpine sh -c "pwd; ls" | |
Test-exercise-3: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Start nginx with custom port, config and templates | |
run: docker run -d --rm -p 8888:8080 -e NGINX_PORT=8080 -v ${PWD}/exercise-03/index.html:/usr/share/nginx/html/index.html -v ${PWD}/exercise-03/conf:/etc/nginx/templates nginx | |
- name: Wait for nginx port to be ready | |
timeout-minutes: 1 | |
run: | | |
until timeout 2 bash -c "</dev/tcp/localhost/8888"; do | |
echo . | |
sleep 1 | |
done | |
- name: Check serves custom index.html file | |
run: curl --silent http://127.0.0.1:8888 | grep --silent "My First Heading" | |
Test-exercise-4: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test docker-compose interfaces | |
run: | | |
cd exercise-04/nginx-flask-mongo | |
docker compose up -d | |
docker compose logs web | |
sleep 5 | |
docker compose exec mongo mongosh --eval "db.users.insertOne({name: 'jonas'})" | |
docker compose down | |
Test-exercise-5: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test docker build | |
run: | | |
cd solutions/exercise-05 | |
docker build -t my-python-app -f Dockerfile.6 . | |
docker run -d -p 9091:9091 my-python-app | |
- name: Wait for server to start and be ready | |
# use static sleep because testing port availability will pass before the | |
# server is actually ready to reply with the expected response | |
run: sleep 3 | |
- name: Check server response | |
run: curl --silent http://127.0.0.1:9091 | grep --silent "Hello from your brand new container" | |
Test-exercise-6: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test docker build | |
run: | | |
cd exercise-06 | |
docker build -t ex6-1 1-caching/ | |
docker build -t ex6-2:v1 -f 2-multi-stage-builds-cpp/Dockerfile.1 2-multi-stage-builds-cpp | |
docker build -t ex6-2:v2 -f 2-multi-stage-builds-cpp/Dockerfile.2 2-multi-stage-builds-cpp | |
docker build -t ex6-2:v3 -f 2-multi-stage-builds-cpp/Dockerfile.3 2-multi-stage-builds-cpp | |
Test-exercise-7: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test docker build | |
run: | | |
cd exercise-07 | |
docker build -t ex7 project/ | |
Test-exercise-8: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test docker build | |
run: | | |
cd exercise-08 | |
docker compose up -d --wait || (docker compose logs && exit 1) | |
docker build -t my-alpine-cat . | |
docker image tag my-alpine-cat localhost/my-alpine-cat:v1 | |
docker login -u registry -p ui localhost | |
docker push localhost/my-alpine-cat:v1 | |
docker compose down | |
Test-exercise-9: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test docker build | |
run: | | |
docker build -t nano-app -f solutions/exercise-09/my-nano-app/Dockerfile exercise-09/my-nano-app | |
docker build -t node-app -f solutions/exercise-09/my-node-app/Dockerfile exercise-09/my-node-app | |
Test-exercise-11: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Install docker-scout | |
run: curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s -- | |
- name: Test docker scout | |
run: | | |
cd exercise-11 | |
docker build -t flask-app:v1 . | |
- uses: nick-fields/retry@v2 | |
with: | |
max_attempts: 3 | |
retry_on: error | |
timeout_minutes: 4 | |
command: | | |
docker scout quickview flask-app:v1 | |
Test-exercise-12: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Test sample projects | |
run: | | |
cd exercise-12/1-python | |
docker compose up -d | |
sleep 4 | |
curl --silent http://127.0.0.1:8000 | grep --silent "Hello from the MongoDB client" | |
docker compose down | |
cd ../2-angular | |
docker build -t my-angular-app:test-latest --target test . | |
# docker run -v ${PWD}:/app my-angular-app:test-latest | |
# test -f test-results.xml |