Skip to content

Commit

Permalink
Merge pull request #81 from UoMResearchIT/code-extraction
Browse files Browse the repository at this point in the history
Episode's code extraction
  • Loading branch information
fherreazcue authored Nov 26, 2024
2 parents 94439ed + 8089eed commit f250cd4
Show file tree
Hide file tree
Showing 17 changed files with 1,293 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-close-signal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
mkdir -p ./pr
printf ${{ github.event.number }} > ./pr/NUM
- name: Upload Diff
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pr
path: ./pr
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
contents: write
steps:
- name: 'Checkout md outputs'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: md-outputs
path: built
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pr-receive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: "Upload PR number"
id: upload
if: ${{ always() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pr
path: ${{ github.workspace }}/NR
Expand Down Expand Up @@ -58,10 +58,10 @@ jobs:
MD: ${{ github.workspace }}/site/built
steps:
- name: "Check Out Main Branch"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Check Out Staging Branch"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: md-outputs
path: ${{ env.MD }}
Expand Down Expand Up @@ -107,20 +107,20 @@ jobs:
shell: Rscript {0}

- name: "Upload PR"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pr
path: ${{ env.PR }}

- name: "Upload Diff"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: diff
path: ${{ env.CHIVE }}
retention-days: 1

- name: "Upload Build"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: built
path: ${{ env.MD }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sandpaper-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
steps:

- name: "Checkout Lesson"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Set up R"
uses: r-lib/actions/setup-r@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
needed: ${{ steps.renv.outputs.exists }}
steps:
- name: "Checkout Lesson"
uses: actions/checkout@v3
uses: actions/checkout@v4
- id: renv
run: |
if [[ -d renv ]]; then
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
steps:

- name: "Checkout Lesson"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Set up R"
uses: r-lib/actions/setup-r@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
if: ${{ needs.check_token.outputs.workflow == 'true' }}
steps:
- name: "Checkout Repository"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Update Workflows
id: update
Expand Down
141 changes: 141 additions & 0 deletions code/episodes/docker-cli-toolkit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@




## Pulling and Listing Images
```bash
docker pull spuacv/spuc:latest
```

## The structure of a Docker command
Image: A diagram showing the syntactic structure of a Docker command

## Listing Images
```bash
docker image ls
```
## Inspecting
```bash
docker inspect spuacv/spuc:latest
```
```bash
docker inspect spuacv/spuc:latest -f "Command: {{.Config.Cmd}}"
```
```bash
docker inspect spuacv/spuc:latest -f "Entrypoint: {{.Config.Entrypoint}}"
```
```bash
docker inspect spuacv/spuc:latest -f $'Command: {{.Config.Cmd}}\nEntrypoint: {{.Config.Entrypoint}}'
```

## Default Command
Image: A diagram representing the lifecycle of a container

### Further examples of container lifecycle
Image: Further details and examples of the lifecycle of a container


## Running
```bash
docker run spuacv/spuc:latest
```
```bash
docker run -d spuacv/spuc:latest
```
## Listing Containers
```bash
docker ps
```
```bash
docker ps -a
```
## Logs
```bash
docker logs ecstatic_nightingale
```
```bash
curl -X PUT localhost:8321/unicorn_spotted?location=moon\&brightness=100
```
## Exposing ports
```bash
docker run -d -p 8321:8321 spuacv/spuc:latest
```
```bash
docker ps
```
```bash
curl -X PUT localhost:8321/unicorn_spotted?location=moon\&brightness=100
```
```bash
docker logs unruffled_noyce
```
## Setting the name of a container
```bash
docker run -d --name spuc_container -p 8321:8321 spuacv/spuc:latest
```
```bash
docker stop unruffled_noyce
docker rm unruffled_noyce
```

### Killing containers
```bash
docker kill ecstatic_nightingale
```

```bash
docker run -d --name spuc_container -p 8321:8321 spuacv/spuc:latest
```
```bash
docker logs -f spuc_container
```

### Logs

## Executing commands in a running container
```bash
docker exec spuc_container cat config/print.config
```
```bash
docker exec -it spuc_container bash
```
```bash
apt update
apt install tree
tree
```

## Interactive sessions
```bash
docker run -it alpine:latest
```

## Reviving Containers
```bash
docker kill spuc_container
```
```bash
docker start spuc_container
```
```bash
docker stats
```
## Cleaning up
```bash
docker kill spuc_container
```
```bash
docker rm spuc_container
```
```bash
docker image rm spuacv/spuc:latest
```
```bash
docker system prune
```
### Automatic cleanup
```bash
docker run -d --rm --name spuc_container -p 8321:8321 spuacv/spuc:latest
```


70 changes: 70 additions & 0 deletions code/episodes/docker-compose-microservices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@




## Microservices
## Microservices in Docker Compose
```yml
services:
proxy:
image: 'jc21/nginx-proxy-manager:latest'
ports:
- '80:80'
- '443:443'
depends_on:
- authelia
healthcheck:
test: ["CMD", "/bin/check-health"]

whoami:
image: docker.io/traefik/whoami

authelia:
image: authelia/authelia
depends_on:
lldap:
condition: service_healthy
volumes:
- ${PWD}/config/authelia/config:/config
environment:
AUTHELIA_DEFAULT_REDIRECTION_URL: https://whoami.${URL}
AUTHELIA_STORAGE_POSTGRES_HOST: authelia-postgres
AUTHELIA_AUTHENTICATION_BACKEND_LDAP_URL: ldap://apperture-ldap:3890

lldap:
image: nitnelave/lldap:stable
depends_on:
lldap-postgres:
condition: service_healthy
environment:
LLDAP_LDAP_BASE_DN: dc=example,dc=com
LLDAP_DATABASE_URL: postgres://user:pass@lldap-postgres/dbname
volumes:
- lldap-data:/data

lldap-postgres:
image: postgres
volumes:
- lldap-postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U lldap"]

volumes:
lldap-data:
lldap-postgres-data:
```
Image: Apperture Services: Showing a user accessing WhoAmI via the web portal, which is protected by Authelia, which authenticates against an LDAP server, which pulls user data from a Postgres database.
## Combining Stacks
```yml
# SPUC docker-compose.yml

+ networks:
+ apperture:
+ external: true
+ name: apperture_default
```
Image: SPUC and Apperture Services: Showing a user accessing the SPUC interface via the web portal.
## Rapid extension
Image: SPUC and Apperture Services: Showing a user accessing the SPUC interface via the web portal, which is protected by Authelia, which authenticates against an LDAP server, which pulls user data from a Postgres database. The SPUC interface communicates with a Postgres database, a RabbitMQ message queue, a Telegraf sensor, and a MinIO object store.
## They Lived Happily Ever After
Image: Thank you for supporting the SPUA!
Loading

0 comments on commit f250cd4

Please sign in to comment.