Skip to content

Commit 5da5a25

Browse files
committed
dev: container overhaul
1 parent 710548b commit 5da5a25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1479
-756
lines changed

.dockerignore

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
.git
2-
.git-blame-ignore
3-
.github
4-
.gitignore
5-
.vscode
6-
bin/
7-
config.toml
8-
config.toml.local
9-
cSpell.json
10-
data.db
11-
docker/
12-
NOTICE
13-
README.md
14-
rustfmt.toml
15-
storage/
16-
target/
1+
/.git
2+
/.git-blame-ignore
3+
/.github
4+
/.gitignore
5+
/.vscode
6+
/bin/
7+
/tracker.*
8+
/cSpell.json
9+
/data.db
10+
/docker/bin/
11+
/NOTICE
12+
/README.md
13+
/rustfmt.toml
14+
/storage/
15+
/target/
16+
/etc/

.env.local

-1
This file was deleted.

.github/workflows/container.yaml

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Container
2+
3+
on:
4+
push:
5+
tags-ignore:
6+
- "!v*"
7+
pull_request:
8+
branches:
9+
- "develop"
10+
- "main"
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
test:
17+
name: Test (Docker)
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- id: setup
22+
name: Setup Toolchain
23+
uses: docker/setup-buildx-action@v2
24+
25+
- id: build
26+
name: Build
27+
uses: docker/build-push-action@v4
28+
with:
29+
file: ./Containerfile
30+
push: false
31+
load: true
32+
tags: torrust-tracker:local
33+
cache-from: type=gha
34+
cache-to: type=gha,mode=max
35+
36+
- id: inspect
37+
name: Inspect
38+
run: docker image inspect torrust-tracker:local
39+
40+
- id: checkout
41+
name: Checkout Repository
42+
uses: actions/checkout@v3
43+
44+
- id: compose
45+
name: Compose
46+
run: docker compose build
47+
48+
context:
49+
name: Context
50+
needs: test
51+
runs-on: ubuntu-latest
52+
53+
outputs:
54+
continue: ${{ steps.check.outputs.continue }}
55+
56+
steps:
57+
- id: check
58+
name: Check Context
59+
run: |
60+
if [[ "${{ github.event_name }}" == "push" && ( "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" || "${{ github.ref }}" == "refs/heads/docker" ) ]] ||
61+
[[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
62+
if [[ "${{ github.repository }}" == "torrust/torrust-tracker" ]]; then
63+
echo "Context is torrust/torrust-tracker, and push is: main, develop, docker, or a tag of v*.*.*"
64+
echo "continue=true" >> $GITHUB_OUTPUT
65+
fi
66+
fi
67+
68+
secrets:
69+
name: Secrets
70+
needs: context
71+
environment: dockerhub-torrust
72+
if: needs.context.outputs.continue == 'true'
73+
runs-on: ubuntu-latest
74+
75+
outputs:
76+
continue: ${{ steps.check.outputs.continue }}
77+
78+
steps:
79+
- id: check
80+
name: Check
81+
env:
82+
DOCKER_HUB_ACCESS_TOKEN: "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"
83+
if: "${{ env.DOCKER_HUB_ACCESS_TOKEN != '' }}"
84+
run: echo "continue=true" >> $GITHUB_OUTPUT
85+
86+
publish:
87+
name: Publish
88+
environment: dockerhub-torrust
89+
needs: secrets
90+
if: needs.secrets.outputs.continue == 'true'
91+
runs-on: ubuntu-latest
92+
93+
steps:
94+
- id: meta
95+
name: Docker meta
96+
uses: docker/metadata-action@v4
97+
with:
98+
images: |
99+
"${{ secrets.DOCKER_HUB_USERNAME }}/${{secrets.DOCKER_HUB_REPOSITORY_NAME }}"
100+
tags: |
101+
type=ref,event=branch
102+
type=ref,event=pr
103+
type=semver,pattern={{version}}
104+
type=semver,pattern={{major}}.{{minor}}
105+
106+
- id: login
107+
name: Login to Docker Hub
108+
uses: docker/login-action@v2
109+
with:
110+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
111+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
112+
113+
- id: setup
114+
name: Setup Toolchain
115+
uses: docker/setup-buildx-action@v2
116+
117+
- name: Build and push
118+
uses: docker/build-push-action@v4
119+
with:
120+
file: ./Containerfile
121+
push: ${{ github.event_name != 'pull_request' }}
122+
tags: ${{ steps.meta.outputs.tags }}
123+
labels: ${{ steps.meta.outputs.labels }}
124+
cache-from: type=gha
125+
cache-to: type=gha,mode=max

.github/workflows/publish_docker_image.yml

-86
This file was deleted.

.github/workflows/test_docker.yml

-26
This file was deleted.

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
/.coverage/
44
/.idea/
55
/.vscode/launch.json
6-
/config.toml
6+
/tracker.toml
77
/data.db
88
/database.db
99
/database.json.bz2
1010
/storage/
1111
/target
12+
/tracker.*

.vscode/settings.json

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"[rust]": {
3-
"editor.formatOnSave": true
4-
},
5-
"rust-analyzer.checkOnSave": true,
6-
"rust-analyzer.check.command": "clippy",
7-
"rust-analyzer.check.allTargets": true,
8-
"rust-analyzer.check.extraArgs": [
9-
"--",
10-
"-D",
11-
"clippy::correctness",
12-
"-D",
13-
"clippy::suspicious",
14-
"-W",
15-
"clippy::complexity",
16-
"-W",
17-
"clippy::perf",
18-
"-W",
19-
"clippy::style",
20-
"-W",
21-
"clippy::pedantic",
22-
],
2+
"[rust]": {
3+
"editor.formatOnSave": true
4+
},
5+
"rust-analyzer.checkOnSave": true,
6+
"rust-analyzer.check.command": "clippy",
7+
"rust-analyzer.check.allTargets": true,
8+
"rust-analyzer.check.extraArgs": [
9+
"--",
10+
"-D",
11+
"clippy::correctness",
12+
"-D",
13+
"clippy::suspicious",
14+
"-W",
15+
"clippy::complexity",
16+
"-W",
17+
"clippy::perf",
18+
"-W",
19+
"clippy::style",
20+
"-W",
21+
"clippy::pedantic",
22+
],
2323
}

Cargo.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)