Skip to content

Commit 8fa301a

Browse files
committed
ci: nightly container builds
1 parent 143f6fa commit 8fa301a

File tree

6 files changed

+117
-9
lines changed

6 files changed

+117
-9
lines changed

.containerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/target
2+
# nix build result
3+
result
4+
log
5+
tmp/
6+
.git
7+
.github
8+
.gitignore
9+
Containerfile
10+
.containerignore
11+
DEFAULT_LICENSE
12+
flake.lock
13+
flake.nix
14+
README.md

.github/workflows/container.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: build
2+
on:
3+
schedule:
4+
- cron: "00 00 * * *"
5+
workflow_dispatch:
6+
7+
env:
8+
IMAGE_NAME: crawlspace
9+
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
10+
11+
jobs:
12+
check-last-commit:
13+
runs-on: ubuntu-24.04
14+
name: Check last commit date
15+
outputs:
16+
run-approved: ${{ steps.confirm-run.outputs.run-approved }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- id: confirm-run
20+
continue-on-error: true
21+
name: Check last commit is <24h old
22+
if: ${{ github.event_name == 'schedule' }}
23+
run: test -z $(git ref-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=run-approved::false"
24+
25+
build-container:
26+
name: Build and push container
27+
runs-on: ubuntu-24.04
28+
permissions:
29+
contents: read
30+
packages: write
31+
needs: check-last-commit
32+
if: ${{ needs.check-last-commit.outputs.run-approved != 'false' }}
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Generate tag
38+
id: generate-tags
39+
run: |
40+
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
41+
echo "date=$(date +%m%d%Y)" >> $GITHUB_OUTPUT
42+
43+
- name: Image Metadata
44+
uses: docker/metadata-action@v4
45+
with:
46+
images: |
47+
${{ env.IMAGE_NAME }}
48+
labels: |
49+
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/xoogware/crawlspace/main/README.md
50+
51+
- name: Build image
52+
id: build
53+
uses: redhat-actions/buildah-build@v2
54+
with:
55+
containerfiles: |
56+
./Containerfile
57+
image: ${{ env.IMAGE_NAME }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
oci: false
60+
tags: |
61+
${{ steps.generate-tags.outputs.sha }}
62+
${{ steps.generate-tags.outputs.date }}
63+
nightly
64+
65+
- name: Push
66+
uses: redhat-actions/push-to-registry@v2
67+
with:
68+
image: ${{ steps.build.outputs.image }}
69+
tags: ${{ steps.build.outputs.tags }}
70+
registry: ${{ env.IMAGE_REGISTRY }}
71+
username: ${{ github.actor }}
72+
password: ${{ github.token }}
73+

Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bitfield-struct = "0.9.2"
2828
byteorder = "1.5.0"
2929
bytes = "1.8.0"
3030
cfb8 = { version = "0.8.1", optional = true }
31-
clap = { version = "4.5.20", features = ["derive"] }
31+
clap = { version = "4.5.20", features = ["derive", "env"] }
3232
color-eyre = "0.6.3"
3333
fastanvil = { git = "https://github.com/owengage/fastnbt.git" }
3434
fastnbt = { git = "https://github.com/owengage/fastnbt.git" }
@@ -53,3 +53,11 @@ lan = []
5353
timings = []
5454

5555
full = ["compression", "encryption"]
56+
57+
[profile.release-stripped]
58+
inherits = "release"
59+
strip = "symbols"
60+
61+
[profile.release-lto]
62+
inherits = "release-stripped"
63+
lto = true

Containerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM rust:1.82 AS build
2+
3+
WORKDIR /app
4+
COPY . .
5+
6+
RUN cargo build --profile release-lto --features compression
7+
8+
FROM ubi9/ubi-micro
9+
WORKDIR /app
10+
COPY --from=build /app/target/release-lto/crawlspace .
11+
12+
CMD ["/app/crawlspace"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ podman pull ghcr.io/xoogware/crawlspace:latest
4848
```
4949
then run with the world mounted read-only:
5050
```bash
51-
podman run --rm -v=./tmp/DIM1:/world:ro crawlspace -- /world
51+
podman run --rm --read-only -v=./tmp/DIM1:/world:ro,Z -e="LIMBO_WORLD=/world" -p=8006:25565 crawlspace
5252
```
5353

5454
# Configuration

src/args.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,29 @@ use clap::Parser;
2222
#[derive(Debug, Parser)]
2323
pub struct Args {
2424
/// The directory to load the map from. Should be DIM1, or the equivalent renamed folder.
25+
#[arg(env = "LIMBO_WORLD")]
2526
pub map_dir: String,
2627
/// The address to serve crawlspace on.
27-
#[arg(short, long, default_value = "[::]")]
28+
#[arg(short, long, default_value = "[::]", env = "LIMBO_ADDRESS")]
2829
pub addr: String,
2930
/// The port to serve crawlspace on. Defaults to 25565 if not set.
30-
#[arg(short, long, default_value = "25565")]
31+
#[arg(short, long, default_value = "25565", env = "LIMBO_PORT")]
3132
pub port: u16,
3233
/// The x coordinate of the spawnpoint.
33-
#[arg(short = 'x', long, default_value = "0")]
34+
#[arg(short = 'x', long, default_value = "0", env = "LIMBO_SPAWN_X")]
3435
pub spawn_x: f64,
3536
/// The y coordinate of the spawnpoint.
36-
#[arg(short = 'y', long, default_value = "100")]
37+
#[arg(short = 'y', long, default_value = "100", env = "LIMBO_SPAWN_Y")]
3738
pub spawn_y: f64,
3839
/// The z coordinate of the spawnpoint.
39-
#[arg(short = 'z', long, default_value = "0")]
40+
#[arg(short = 'z', long, default_value = "0", env = "LIMBO_SPAWN_Z")]
4041
pub spawn_z: f64,
4142
/// The border radius, centered around the spawnpoint. Defaults to 10 chunks. One
4243
/// chunk past the border will be loaded.
43-
#[arg(short = 'b', long, default_value = "160")]
44+
#[arg(short = 'b', long, default_value = "160", env = "LIMBO_BORDER_RADIUS")]
4445
pub border_radius: i32,
4546
#[arg(short, long, default_value = "Limbo")]
4647
pub motd: String,
47-
#[arg(long, default_value = "500")]
48+
#[arg(long, default_value = "500", env = "LIMBO_MAX_PLAYERS")]
4849
pub max_players: usize,
4950
}

0 commit comments

Comments
 (0)