Skip to content

Commit

Permalink
Initial offering
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew Sutherland committed Jul 17, 2021
1 parent 6136a0f commit 1d087a9
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
@@ -0,0 +1,25 @@
# Overview

Use at your own risk

Start by editing the `docker-compose.yaml` to suit.

The idea is that persistent storage is bind mounted in so upgrades and restarts require no further intervention beyond initial setup. The containers assume you already have a chia config (`~/.chia`), copy this somewhere else e.g `/srv/chia/config` for the bind mount into `/chia/.chia`. The container imports your key from `/chia/.chia/nmemonic.txt` file see `gui/root/etc/cont-init.d/10-chiainit.sh`.

# GUI

Run the container
```
docker-compose -p chia up --build -d
```
The gui will be available on port `5800`, it takes a couple minutes to startup

## First time init

TODO can't remember

# Issues

- The GUI tries to start all the services (which were already started by s6) this causes errors to show in logs, these can be ignored
- Lots of TODOs

23 changes: 23 additions & 0 deletions docker-compose.yaml
@@ -0,0 +1,23 @@
version: "3.2"
services:
gui:
build: gui
ports:
- 8444:8444
- 8447:8447
- 5800:5800
environment:
TZ: "America/Denver"
USER_ID: 1000
GROUP_ID: 1000
sysctls:
net.ipv6.conf.lo.disable_ipv6: 0
volumes:
- gui_config:/config
- /srv/chia/config:/chia/.chia
- /tank/chia/plots:/chia-plots-0
restart: always

volumes:
gui_config:

82 changes: 82 additions & 0 deletions gui/Dockerfile
@@ -0,0 +1,82 @@
FROM jlesage/baseimage-gui:ubuntu-18.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
# Stuff for chia install
RUN apt-get install -y \
bash git lsb-release sudo apt-utils curl wget bc \
python3.7-venv python3.7-distutils \
nodejs libxss1
# Electron build deps,
# TODO replace with proper runtime deps
RUN apt-get install -y \
build-essential clang libdbus-1-dev libgtk-3-dev \
libnotify-dev libgnome-keyring-dev \
libasound2-dev libcap-dev libcups2-dev libxtst-dev \
libxss1 libnss3-dev gcc-multilib g++-multilib curl \
gperf bison python-dbusmock openjdk-8-jre

# Update npm for 1804
RUN npm install -g n \
&& n stable

# Cleanup inherited user management and make our own chia user
# TODO ideally /config would be home but since it is marked as a
# volume in a previous layer we can't use it because any changes
# we make will be lost, this is notable for the npm install later
RUN rm /etc/cont-init.d/00-app-user-map.sh \
&& rm /etc/cont-init.d/00-set-home.sh \
&& useradd -d /chia -m -u 1000 -U -s /bin/bash chia
#&& useradd -d /chia -m -u 1000 -U -G sudo -s /bin/bash chia \
#&& echo "%sudo ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers

# Move xdg off /cache
# TODO XDG_DATA_HOME controls where python_keyring dir is
# combine with ~/.pki to avoid key import
ENV XDG_DATA_HOME=/chia/xdg/data \
XDG_CONFIG_HOME=/chia/xdg/config \
XDG_CACHE_HOME=/chia/xdg/cache

WORKDIR /chia
USER chia

# Clone chia
ARG BRANCH="latest"
RUN git clone --branch ${BRANCH} --recursive \
https://github.com/Chia-Network/chia-blockchain.git
COPY patches/ chia-blockchain/

# Install chia
RUN cd chia-blockchain \
&& python3.7 -m venv venv \
&& . ./venv/bin/activate \
&& python -m pip install --upgrade pip \
&& python -m pip install wheel \
&& python -m pip install --extra-index-url https://pypi.chia.net/simple/ miniupnpc==2.2.2 \
&& python -m pip install -e . --extra-index-url https://pypi.chia.net/simple/

# Install chia gui
# TODO still need to deal with all the startService calls in patch
# since we manage the daemons the gui should not try to start them
RUN cd chia-blockchain/chia-blockchain-gui \
&& patch -p1 < ../0001-gui-docker-compat.patch \
&& . ../venv/bin/activate \
&& npm install \
&& (npm audit fix || true) \
&& npm run build

USER 0

ENV PATH="/chia/chia-blockchain/venv/bin/:$PATH" \
APP_USER=chia \
APP_NAME=ChiaGUI

# configurables from previous layers
# TAKE_CONFIG_OWNERSHIP=1
# DISPLAY_HEIGHT=768
# DISPLAY_WIDTH=1280

COPY root/ /

# TODO versioning label

47 changes: 47 additions & 0 deletions gui/patches/0001-gui-docker-compat.patch
@@ -0,0 +1,47 @@
From f27d1ec5043941860376753166d9e35acef32fea Mon Sep 17 00:00:00 2001
From: Nobody
Date: Thu, 15 Jul 2021 16:04:21 -0600
Subject: [PATCH] gui docker compat

---
package.json | 4 ++--
src/util/config.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/package.json b/package.json
index 90e3babf..7b199a20 100644
--- a/package.json
+++ b/package.json
@@ -11,14 +11,14 @@
},
"scripts": {
"start": "cross-env NODE_ENV=development webpack serve --config ./webpack.react.babel.ts",
- "dev:electron": "cross-env NODE_ENV=development webpack --config webpack.electron.babel.ts --mode development && electron .",
+ "dev:electron": "cross-env NODE_ENV=development webpack --config webpack.electron.babel.ts --mode development && electron . --no-sandbox",
"dev:react": "cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 webpack serve --config webpack.react.babel.ts --mode development",
"dev": "npm run locale && concurrently --kill-others \"npm run dev:react\" \"npm run dev:electron\"",
"dev:fast": "concurrently --kill-others \"npm run dev:react\" \"npm run dev:electron\"",
"build:electron": "cross-env NODE_ENV=production webpack --config ./webpack.electron.babel.ts",
"build:react": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack --config ./webpack.react.babel.ts",
"build": "npm run locale && npm run build:electron && npm run build:react",
- "electron": "electron .",
+ "electron": "electron . --no-sandbox",
"locale:extract": "lingui extract",
"locale:compile": "lingui compile",
"locale": "lingui extract && lingui compile",
diff --git a/src/util/config.js b/src/util/config.js
index 5faac066..94311e94 100644
--- a/src/util/config.js
+++ b/src/util/config.js
@@ -49,7 +49,7 @@ function loadConfig(net) {

function manageDaemonLifetime() {
// only start/stop daemon if it is running locally
- return self_hostname === 'localhost';
+ return false; //self_hostname === 'localhost';
}

module.exports = {
--
2.30.2

13 changes: 13 additions & 0 deletions gui/root/etc/cont-init.d/00-0userid.sh
@@ -0,0 +1,13 @@
#!/usr/bin/with-contenv sh

PUID=${USER_ID:-1000}
PGID=${GROUP_ID:-1000}

groupmod -o -g "$PGID" chia
usermod -o -u "$PUID" chia

echo "
chia uid: $(id -u chia)
chia gid: $(id -g chia)
"

6 changes: 6 additions & 0 deletions gui/root/etc/cont-init.d/10-chiainit.sh
@@ -0,0 +1,6 @@
#!/usr/bin/with-contenv sh
export HOME=/chia

s6-setuidgid chia chia init
s6-setuidgid chia chia keys add -f ${HOME}/.chia/mnemonic.txt

4 changes: 4 additions & 0 deletions gui/root/etc/services.d/chiadaemon/run
@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv sh
export HOME=/chia
exec s6-setuidgid chia chia run_daemon

1 change: 1 addition & 0 deletions gui/root/etc/services.d/chiafarmer/chiadaemon.dep
@@ -0,0 +1 @@
#Dep
4 changes: 4 additions & 0 deletions gui/root/etc/services.d/chiafarmer/finish
@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv sh
export HOME=/chia
rm ${HOME}/.chia/mainnet/run/chia_farmer.pid

5 changes: 5 additions & 0 deletions gui/root/etc/services.d/chiafarmer/run
@@ -0,0 +1,5 @@
#!/usr/bin/with-contenv sh
#s6-svwait -u /var/run/s6/services/chiadaemon
export HOME=/chia
exec s6-setuidgid chia chia_farmer

1 change: 1 addition & 0 deletions gui/root/etc/services.d/chiafullnode/chiadaemon.dep
@@ -0,0 +1 @@
#Dep
4 changes: 4 additions & 0 deletions gui/root/etc/services.d/chiafullnode/finish
@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv sh
export HOME=/chia
rm ${HOME}/.chia/mainnet/run/chia_full_node.pid

5 changes: 5 additions & 0 deletions gui/root/etc/services.d/chiafullnode/run
@@ -0,0 +1,5 @@
#!/usr/bin/with-contenv sh
#s6-svwait -u /var/run/s6/services/chiadaemon
export HOME=/chia
exec s6-setuidgid chia chia_full_node

1 change: 1 addition & 0 deletions gui/root/etc/services.d/chiaharvester/chiadaemon.dep
@@ -0,0 +1 @@
#Dep
4 changes: 4 additions & 0 deletions gui/root/etc/services.d/chiaharvester/finish
@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv sh
export HOME=/chia
rm ${HOME}/.chia/mainnet/run/chia_harvester.pid

5 changes: 5 additions & 0 deletions gui/root/etc/services.d/chiaharvester/run
@@ -0,0 +1,5 @@
#!/usr/bin/with-contenv sh
#s6-svwait -u /var/run/s6/services/chiadaemon
export HOME=/chia
exec s6-setuidgid chia chia_harvester

1 change: 1 addition & 0 deletions gui/root/etc/services.d/chiawallet/chiadaemon.dep
@@ -0,0 +1 @@
#Dep
4 changes: 4 additions & 0 deletions gui/root/etc/services.d/chiawallet/finish
@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv sh
export HOME=/chia
rm ${HOME}/.chia/mainnet/run/chia_wallet.pid

5 changes: 5 additions & 0 deletions gui/root/etc/services.d/chiawallet/run
@@ -0,0 +1,5 @@
#!/usr/bin/with-contenv sh
#s6-svwait -u /var/run/s6/services/chiadaemon
export HOME=/chia
exec s6-setuidgid chia chia_wallet

11 changes: 11 additions & 0 deletions gui/root/startapp.sh
@@ -0,0 +1,11 @@
#!/bin/bash

export HOME=/chia

. ${HOME}/chia-blockchain/venv/bin/activate

cd ${HOME}/chia-blockchain/chia-blockchain-gui

sleep 20 # TODO proper dependency management
npm run electron

0 comments on commit 1d087a9

Please sign in to comment.