Skip to content

Commit a4cd5ad

Browse files
committed
docker is back
1 parent bc8389c commit a4cd5ad

File tree

6 files changed

+231
-3
lines changed

6 files changed

+231
-3
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docker
2+
target

.github/workflows/docker.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Docker
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
description: "Release version"
8+
required: true
9+
type: string
10+
default: ""
11+
base_hash:
12+
description: "Commit hash from which to build"
13+
required: true
14+
type: string
15+
default: ""
16+
publish:
17+
description: "Publish to Docker Hub"
18+
required: true
19+
type: boolean
20+
default: false
21+
workflow_call:
22+
inputs:
23+
release_version:
24+
description: "Release version"
25+
required: true
26+
type: string
27+
default: ""
28+
base_hash:
29+
description: "Commit hash from which to build"
30+
required: true
31+
type: string
32+
default: ""
33+
publish:
34+
description: "Publish to Docker Hub"
35+
required: true
36+
type: boolean
37+
default: false
38+
39+
env:
40+
IROH_FORCE_STAGING_RELAYS: "1"
41+
42+
jobs:
43+
build_and_publish:
44+
timeout-minutes: 30
45+
name: Docker
46+
runs-on: [self-hosted, linux, X64]
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Login to Docker Hub
55+
uses: docker/login-action@v3
56+
with:
57+
username: ${{ secrets.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_TOKEN }}
59+
60+
- name: Prep dirs
61+
run: |
62+
mkdir -p bins/linux/amd64
63+
mkdir -p bins/linux/arm64
64+
65+
- name: Setup awscli on linux
66+
run: |
67+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
68+
unzip awscliv2.zip
69+
sudo ./aws/install --update
70+
71+
- name: Set aws credentials
72+
run: |
73+
echo "AWS_ACCESS_KEY_ID=${{secrets.S3_ACCESS_KEY_ID}}" >> $GITHUB_ENV
74+
echo "AWS_SECRET_ACCESS_KEY=${{secrets.S3_ACCESS_KEY}}" >> $GITHUB_ENV
75+
echo "AWS_DEFAULT_REGION=us-west-2" >> $GITHUB_ENV
76+
77+
- name: Fetch release binaries
78+
run: |
79+
aws s3 cp s3://vorc/iroh-relay-linux-amd64-${{ inputs.base_hash }} bins/linux/amd64/iroh-relay
80+
aws s3 cp s3://vorc/iroh-dns-server-linux-amd64-${{ inputs.base_hash }} bins/linux/amd64/iroh-dns-server
81+
82+
aws s3 cp s3://vorc/iroh-relay-linux-aarch64-${{ inputs.base_hash }} bins/linux/arm64/iroh-relay
83+
aws s3 cp s3://vorc/iroh-dns-server-linux-aarch64-${{ inputs.base_hash }} bins/linux/arm64/iroh-dns-server
84+
85+
- name: Build Docker image (iroh-relay)
86+
uses: docker/build-push-action@v6
87+
with:
88+
context: .
89+
push: ${{ inputs.publish }}
90+
tags: n0computer/iroh-relay:latest,n0computer/iroh-relay:${{ inputs.release_version }}
91+
target: iroh-relay
92+
platforms: linux/amd64,linux/arm64/v8
93+
file: docker/Dockerfile.ci
94+
95+
- name: Build Docker image (iroh-dns-server)
96+
uses: docker/build-push-action@v6
97+
with:
98+
context: .
99+
push: ${{ inputs.publish }}
100+
tags: n0computer/iroh-dns-server:latest,n0computer/iroh-dns-server:${{ inputs.release_version }}
101+
target: iroh-dns-server
102+
platforms: linux/amd64,linux/arm64/v8
103+
file: docker/Dockerfile.ci

.github/workflows/release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ env:
4242
RUSTDOCFLAGS: -Dwarnings
4343
MSRV: "1.76"
4444
SCCACHE_CACHE_SIZE: "50G"
45-
BIN_NAMES: "iroh,iroh-relay,iroh-dns-server"
45+
BIN_NAMES: "iroh-relay,iroh-dns-server"
4646
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
4747

4848
jobs:
@@ -234,14 +234,12 @@ jobs:
234234
- name: push release
235235
if: matrix.os != 'windows-latest'
236236
run: |
237-
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh s3://vorc/iroh-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
238237
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-relay s3://vorc/iroh-relay-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
239238
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
240239
241240
- name: push release latest
242241
if: matrix.os != 'windows-latest' && (github.event.inputs.mark_latest == 'true' || github.event_name == 'push')
243242
run: |
244-
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh s3://vorc/iroh-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
245243
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-relay s3://vorc/iroh-relay-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
246244
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
247245

docker/Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM rust:alpine AS chef
2+
3+
RUN update-ca-certificates
4+
RUN apk add --no-cache musl-dev openssl-dev pkgconfig
5+
RUN cargo install cargo-chef
6+
WORKDIR /iroh
7+
8+
FROM chef AS planner
9+
COPY . .
10+
RUN cargo chef prepare --recipe-path recipe.json
11+
12+
### Builder image
13+
FROM chef AS rust_builder
14+
15+
RUN update-ca-certificates
16+
RUN apk add --no-cache musl-dev openssl-dev pkgconfig
17+
18+
COPY --from=planner /iroh/recipe.json recipe.json
19+
# Build dependencies - this is the caching Docker layer!
20+
RUN cargo chef cook --release --recipe-path recipe.json
21+
22+
WORKDIR /iroh
23+
24+
# copy entire workspace
25+
COPY . .
26+
27+
RUN cargo build --release --all-features
28+
29+
### Target image
30+
FROM alpine:latest AS iroh-relay
31+
32+
RUN apk update && apk add ca-certificates && update-ca-certificates
33+
34+
# Copy our build, changing owndership to distroless-provided "nonroot" user,
35+
# (65532:65532)
36+
COPY --from=rust_builder /iroh/target/release/iroh-relay /iroh-relay
37+
38+
RUN chmod +x /iroh-relay
39+
40+
WORKDIR /
41+
42+
# expose the default ports
43+
# http, https, stun, metrics
44+
EXPOSE 80 443 3478/udp 9090
45+
ENTRYPOINT ["/iroh-relay"]
46+
CMD [""]
47+
48+
### Target image
49+
FROM alpine:latest AS iroh-dns-server
50+
51+
RUN apk update && apk add ca-certificates && update-ca-certificates
52+
53+
# Copy our build, changing owndership to distroless-provided "nonroot" user,
54+
# (65532:65532)
55+
COPY --from=rust_builder /iroh/target/release/iroh-dns-server /iroh-dns-server
56+
57+
RUN chmod +x /iroh-dns-server
58+
59+
WORKDIR /
60+
61+
# expose the default ports
62+
# dns, metrics
63+
EXPOSE 53/udp 9090
64+
ENTRYPOINT ["/iroh-dns-server"]
65+
CMD [""]

docker/Dockerfile.ci

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
### Base image for iroh-relay and iroh-dns-server
2+
FROM alpine:latest AS base
3+
RUN apk update && apk add ca-certificates && update-ca-certificates
4+
5+
### Target image
6+
FROM base AS iroh-relay
7+
ARG TARGETPLATFORM
8+
9+
COPY bins/${TARGETPLATFORM}/iroh-relay /iroh-relay
10+
11+
RUN chmod +x /iroh-relay
12+
13+
WORKDIR /
14+
15+
# expose the default ports
16+
# http, https, stun, metrics
17+
EXPOSE 80 443 3478/udp 9090
18+
ENTRYPOINT ["/iroh-relay"]
19+
CMD [""]
20+
21+
### Target image
22+
FROM base AS iroh-dns-server
23+
ARG TARGETPLATFORM
24+
25+
COPY bins/${TARGETPLATFORM}/iroh-dns-server /iroh-dns-server
26+
27+
RUN chmod +x /iroh-dns-server
28+
29+
WORKDIR /
30+
31+
# expose the default ports
32+
# dns, metrics
33+
EXPOSE 53/udp 9090
34+
ENTRYPOINT ["/iroh-dns-server"]
35+
CMD [""]

docker/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Iroh Docker Images
2+
3+
## Intro
4+
5+
A set of docker images provided to easily run iroh in a containerized environment.
6+
Features `iroh-relay` and `iroh-dns-server`.
7+
8+
The provided `Docker` files are intended for CI use but can be also manually built.
9+
10+
## Building
11+
12+
- All commands are run from the root folder
13+
- If you're on macOS run `docker buildx build -f docker/Dockerfile --target iroh-relay --platform linux/arm64/v8 --tag n0computer/iroh-relay:latest .`
14+
- If you're on linux run `docker buildx build -f docker/Dockerfile --target iroh-relay --platform linux/amd64 --tag n0computer/iroh-relay:latest .`
15+
- Switch out `--target iroh-relay` for `iroh-dns-server`
16+
17+
## Running
18+
19+
### iroh-relay
20+
21+
- Provide a config file: `docker run -v /path/to/iroh-relay.conf:/config/iroh-relay.conf -p 80:80 -p 443:443 -p 3478:3478/udp -p 9090:9090 -it n0computer/iroh-relay:latest <params> --config /config/iroh-relay.conf`
22+
23+
### iroh-dns-server
24+
25+
- Provide a config file: `docker run -v /path/to/iroh-dns-server.conf:/config/iroh-dns-server.conf -p 53:53/udp -p 9090:9090 -it n0computer/iroh-dns-server:latest <params> --config /config/iroh-dns-server.conf`

0 commit comments

Comments
 (0)