Skip to content

Commit f55e5a6

Browse files
authored
Docker image + automatic GitHub image registry hosting + compose.yml (#707)
* Dockerfile - Added * Dockerfile - Added build depedencies and upgrade system * Create docker.yml Signed-off-by: Tristan B. Velloza Kildaire <deavmi@redxen.eu> * Dockerfile - build the daemon and set entry point for running * Dockerfile - FIxed ptha * d * compose - added initial docker compose file * test * Dockerfile - Removed * Added env file Added more commands * try copy now * disable for now * d * d * d * d * d * d * d * DOckerfile - try this * Dockerfile - Copy needs absolute path, * d * d * d * ss * ockerfile - Use seperate stage * compose - Add access to driver control file for making `tun` files (in whatever ns we are in) - Added capability to allow just that * Dockerfile - Disable stage for nwo * Revert "Dockerfile" This reverts commit 2bb4ac6. * Dockerfile - Cleaned up * Added logging level selection * Compose - More can now be set * Specify key file * data dir * d * Compose - Fixed * d * d * d * d * j * df * d * d * d * USe this rather * d * d * Compose - Cleaned up * d * d * d * d * sd * d * d * d * j * d * finished * clean edup * d * d * okay that wont' work * Dockerfile - Use `--release` to remove debufg symvols * Dockerfile - Fixed path due to relese mode * g * i * Log silenelty --------- Signed-off-by: Tristan B. Velloza Kildaire <deavmi@redxen.eu>
1 parent 50e4dbe commit f55e5a6

File tree

5 files changed

+141
-0
lines changed

5 files changed

+141
-0
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Dockerfile
2+
compose.yml
3+
.env

.env

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
USER_UID=1000
2+
USER_GID=1000
3+
4+
5+
MYCELIUM_PEERS_STRING="quic://[2a02:1802:5e:0:ec4:7aff:fe51:e36b]:9651"
6+
MYCELIUM_LOG_OPTION=silent
7+
MYCELIUM_DATA_DIR=/tmp/myceliumdata
8+
9+
MYCELIUM_QUIC_PORT=9651
10+
MYCELIUM_TCP_PORT=9651
11+
MYCELIUM_PD_PORT=9650
12+
MYCELIUM_TUN_IFNAME=mycelium0
13+

.github/workflows/docker.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
push:
7+
branches: ['master']
8+
9+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
19+
permissions:
20+
contents: read
21+
packages: write
22+
attestations: write
23+
id-token: write
24+
#
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v5
28+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v3
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
48+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
49+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
50+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
51+
- name: Build and push Docker image
52+
id: push
53+
uses: docker/build-push-action@v6.18.0
54+
with:
55+
platforms: linux/amd64,linux/arm64
56+
context: .
57+
push: true
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
61+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
62+
- name: Generate artifact attestation
63+
uses: actions/attest-build-provenance@v3
64+
with:
65+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
66+
subject-digest: ${{ steps.push.outputs.digest }}
67+
push-to-registry: true
68+

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM debian:latest AS build
2+
3+
# TODO: Add nonnteractive flag for apt
4+
5+
# Upgrade system
6+
RUN apt update
7+
RUN apt upgrade -y
8+
9+
# Install build dependencies
10+
RUN apt install rustc -y
11+
12+
# Copy across data
13+
RUN mkdir /src
14+
COPY . /src
15+
WORKDIR /src
16+
17+
# target: myceliumd - the routing daemon
18+
FROM build AS daemonBuild
19+
WORKDIR myceliumd/
20+
RUN cargo build --release
21+
RUN mv target/release/mycelium /bin/mycelium
22+
23+
# TODO: Add copying across of other tools like cli management etc.
24+
# and probably build them seperately
25+
26+
# Clean base image to run fro
27+
FROM debian:latest AS base
28+
COPY --from=daemonBuild /bin/mycelium /bin/mycelium
29+
30+
# Entrypoint
31+
ENTRYPOINT ["/bin/mycelium"]
32+
33+
# TODO: Add health-check command
34+
# HEALTHCHECK /bin/mycelium

compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
myceliumd:
3+
# TODO: You can put image here now, may as well
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
container_name: myceliumd
8+
restart: unless-stopped
9+
network_mode: host
10+
volumes:
11+
# Data directory (keys)
12+
- ${MYCELIUM_DATA_DIR}:/data:z
13+
14+
# Access to TUN/TAP control device node
15+
- /dev/net/tun:/dev/net/tun:z
16+
cap_add:
17+
# Add capability for performing needed network
18+
# manipulation via the `/dev/tun` in order to
19+
# open tun adaptor
20+
- NET_ADMIN
21+
# user: ${USER_UID}:${USER_GID}
22+
# Append the following to the entrypoint exec()
23+
command: "--${MYCELIUM_LOG_OPTION:-debug} --key-file /data/private.key --peers ${MYCELIUM_PEERS_STRING:-\"\"} --quic-listen-port ${MYCELIUM_QUIC_PORT:-9651} --tcp-listen-port ${MYCELIUM_TCP_PORT:-9651} --peer-discovery-port ${MYCELIUM_PD_PORT:-9650} --tun-name ${MYCELIUM_TUN_IFNAME:-mycelium0}"

0 commit comments

Comments
 (0)