Skip to content

Commit

Permalink
new image, now with icecc
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Jan 25, 2024
1 parent c9b5395 commit 4f0c050
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.env
*.env*
config2.toml
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ COPY config.toml /opt/config.toml.tmpl
COPY dist-server.sh /opt/dist-server.sh
RUN chmod +x /opt/dist-server.sh

EXPOSE 8765

ENTRYPOINT ["/opt/dist-server.sh"]
CMD ["/opt/dist-server.sh"]
34 changes: 5 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,12 @@ This repository contains an easy to deploy build cluster node.

2. Join the tailnet on the host machine

3. Run `tailscale ip` to get the IP address of the host machine, take note of this IP address, becuase we will be using this as the `PUBLIC_ADDR` environment variable in the next step.
3. Clone this repository

4. Copy `docker-compose.yml.example` from this repo to `docker-compose.yml` and edit it to your needs
5. Run `docker-compose up -d` to start the build cluster node
4. Run `./update.sh` script to simply add your node to the cluster!

## Quickstart
## Updating

```bash
# set these envars please
Run `./update.sh` script to update your node to the latest version!

TS_KEY=<tskey>
COMPOSE_DIR="~/fyra-build-cluster"
SCHEDULER_URL="http://scheduler"
SERVER_TOKEN="super-secret-token"

tailscale up --authkey $TS_KEY

PUBLIC_ADDR=$(tailscale ip -4)

mkdir -p $COMPOSE_DIR

pushd $COMPOSE_DIR

curl https://github.com/FyraLabs/fyra-build-client/raw/main/docker-compose.yml.example -o docker-compose.yml

echo "PUBLIC_ADDR=$PUBLIC_ADDR" >> .env
echo "SCHEDULER_URL=$SCHEDULER_URL" >> .env
echo "SERVER_TOKEN=$SERVER_TOKEN" >> .env

nano docker-compose.yml

docker compose up -d
```
The compose file also has [watchtower](https://containrrr.dev/watchtower/) enabled, for automatic updates.
14 changes: 8 additions & 6 deletions dist-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CONFIG_FILE=/etc/sccache.conf
CONFIG_TEMPLATE=/opt/config.toml.tmpl
TAILSCALE_SOCKET=/tmp/tailscaled.sock


get_tailscale_ip() {
curl --unix-socket $TAILSCALE_SOCKET -H "Host: local-tailscaled.sock" http://localhost/localapi/v0/status | jq .Self.TailscaleIPs[0] -r
}
Expand All @@ -23,9 +22,10 @@ get_tailscale_ip() {
ip addr show

REQUIRED_ENVS=(
"SERVER_TOKEN"
"SCHEDULER_URL"
"PUBLIC_ADDR"
# "SERVER_TOKEN"
# "SCHEDULER_URL"
"SCHEDULER_ADDR"
"NETNAME"
)

export PUBLIC_ADDR="$PUBLIC_ADDR:10600"
Expand All @@ -39,6 +39,8 @@ done

# We need to somehow get the tailscale IP address of this container

envsubst <$CONFIG_TEMPLATE > $CONFIG_FILE
# envsubst <$CONFIG_TEMPLATE > $CONFIG_FILE

# sccache-dist server --config $CONFIG_FILE

sccache-dist server --config $CONFIG_FILE
iceccd -n $NETNAME -s $SCHEDULER_ADDR -vvv
27 changes: 10 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
sccache-server:
builder:
network_mode: host
container_name: builder
build:
context: .
dockerfile: Dockerfile
Expand All @@ -13,23 +14,15 @@ services:
- /tmp:/tmp
env_file:
- .env
environment:
- SCCACHE_LOG=trace
- .env.auth
labels:
- "com.centurylinklabs.watchtower.enable=true"

# tailscale:
# container_name: tailscale
# network_mode: host
# privileged: true
# image: tailscale/tailscale:latest
# restart: always
# volumes:
# - tailscale:/var/lib/tailscale
# - /tmp/tailscale:/tmp

# env_file:
# - .env
# environment:
# - TS_STATE_DIR=/var/lib/tailscale
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 30

volumes:
cache:
Expand Down
75 changes: 75 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash -xeu

ZIRCON_SCHEDULER="zircon-scheduler"

echo "Welcome to the Fyra Buildsys Setup script!"

echo "Checking for requirements..."

check_tailscale() {
if ! command -v tailscale &>/dev/null; then
echo "tailscale could not be found"
echo "Please install tailscale and try again"
exit 1
fi
}

check_tailnet() {
if ! tailscale ip -4 $ZIRCON_SCHEDULER &>/dev/null; then
echo "tailscale could not find $ZIRCON_SCHEDULER"
echo "Please make sure you are connected to the correct tailnet"
exit 1
fi
}

check_docker() {
if ! command -v docker &>/dev/null; then
echo "docker could not be found"
echo "Please install docker and try again"
exit 1
fi
}

check_docker_compose() {
# "docker compose" v2
if ! sh -c "docker compose version" &>/dev/null; then
echo "docker compose v2 could not be found"
echo "Please install docker compose v2 and try again"
exit 1
fi
}

check() {
check_tailscale
check_tailnet
check_docker
check_docker_compose
}

check

echo "Requirements met!"

echo "Starting setup..."

SCHEDULER_ADDR=$(tailscale ip -4 $ZIRCON_SCHEDULER)
PUBLIC_ADDR=$(tailscale ip -4)

echo """
SCHEDULER_ADDR=$SCHEDULER_ADDR
PUBLIC_ADDR=$PUBLIC_ADDR
NETNAME=zircon
"""

# check if the compose is running

if docker compose ps | grep -q "builder"; then
echo "Builder is already running!"
# Pull and restart

docker compose pull
docker compose up -d --force-recreate
else
echo "Builder is not running, starting it now..."
docker compose up -d
fi

0 comments on commit 4f0c050

Please sign in to comment.