diff options
author | crupest <crupest@outlook.com> | 2022-10-31 20:14:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-10-31 20:14:32 +0800 |
commit | 16bc28ac505aabd9da7dce085054a86db7904d6e (patch) | |
tree | 373c34c6cc699ddde1d09e5755666b1ae260c27c | |
parent | efdfc6feb5744d8ad4bd07e35fa8d662925e3e96 (diff) | |
download | crupest-16bc28ac505aabd9da7dce085054a86db7904d6e.tar.gz crupest-16bc28ac505aabd9da7dce085054a86db7904d6e.tar.bz2 crupest-16bc28ac505aabd9da7dce085054a86db7904d6e.zip |
...
-rw-r--r-- | docker/arch-code-server/Dockerfile (renamed from docker/code-server/Dockerfile) | 0 | ||||
-rwxr-xr-x | docker/arch-code-server/archlinux-setup-user.bash (renamed from docker/code-server/archlinux-setup-user.bash) | 0 | ||||
-rwxr-xr-x | docker/arch-code-server/archlinux-setup.bash (renamed from docker/code-server/archlinux-setup.bash) | 0 | ||||
-rwxr-xr-x | docker/arch-code-server/restore-pacman-conf.py (renamed from docker/code-server/restore-pacman-conf.py) | 0 | ||||
-rw-r--r-- | template/Caddyfile.template | 2 | ||||
-rw-r--r-- | template/docker-compose.yaml.template | 8 | ||||
-rwxr-xr-x | template/generate.py | 5 | ||||
-rw-r--r-- | tool/.gitignore | 1 | ||||
-rwxr-xr-x | tool/download.py | 27 |
9 files changed, 37 insertions, 6 deletions
diff --git a/docker/code-server/Dockerfile b/docker/arch-code-server/Dockerfile index 180cb7e..180cb7e 100644 --- a/docker/code-server/Dockerfile +++ b/docker/arch-code-server/Dockerfile diff --git a/docker/code-server/archlinux-setup-user.bash b/docker/arch-code-server/archlinux-setup-user.bash index 2b39bd2..2b39bd2 100755 --- a/docker/code-server/archlinux-setup-user.bash +++ b/docker/arch-code-server/archlinux-setup-user.bash diff --git a/docker/code-server/archlinux-setup.bash b/docker/arch-code-server/archlinux-setup.bash index c926384..c926384 100755 --- a/docker/code-server/archlinux-setup.bash +++ b/docker/arch-code-server/archlinux-setup.bash diff --git a/docker/code-server/restore-pacman-conf.py b/docker/arch-code-server/restore-pacman-conf.py index 3486dd3..3486dd3 100755 --- a/docker/code-server/restore-pacman-conf.py +++ b/docker/arch-code-server/restore-pacman-conf.py diff --git a/template/Caddyfile.template b/template/Caddyfile.template index df917ac..b2d3dd7 100644 --- a/template/Caddyfile.template +++ b/template/Caddyfile.template @@ -16,5 +16,5 @@ timeline.{{CRUPEST_DOMAIN}} { } code.{{CRUPEST_DOMAIN}} { - reverse_proxy code_server:8080 + reverse_proxy code-server:8080 } diff --git a/template/docker-compose.yaml.template b/template/docker-compose.yaml.template index 5cc6d10..699bc6f 100644 --- a/template/docker-compose.yaml.template +++ b/template/docker-compose.yaml.template @@ -32,15 +32,17 @@ services: - internal code-server: + image: crupest/arch-code-server:latest build: - context: ./docker/code-server + context: ./docker/arch-code-server dockerfile: Dockerfile args: - CRUPEST_USER={{CRUPEST_USER}} - CRUPEST_GROUP={{CRUPEST_GROUP}} - CRUPEST_UID={{CRUPEST_UID}} - CRUPEST_GID={{CRUPEST_GID}} - container_name: code_server + - USE_CHINA_MIRROR={{CRUPEST_IN_CHINA}} + container_name: code-server restart: on-failure:3 volumes: - ./data/code-server:/data @@ -52,7 +54,7 @@ services: caddy: image: caddy:latest container_name: caddy - restart: always + restart: on-failure:3 volumes: - ./Caddyfile:/etc/caddy/Caddyfile - ./site:/srv:ro diff --git a/template/generate.py b/template/generate.py index 1c94cda..a929b07 100755 --- a/template/generate.py +++ b/template/generate.py @@ -8,7 +8,7 @@ import grp import sys required_config_keys = set(["CRUPEST_DOMAIN", "CRUPEST_USER", "CRUPEST_GROUP", "CRUPEST_UID", - "CRUPEST_GID", "CRUPEST_HALO_DB_PASSWORD"]) + "CRUPEST_GID", "CRUPEST_HALO_DB_PASSWORD", "CRUPEST_IN_CHINA"]) print("It's happy to see you!\n") @@ -98,6 +98,7 @@ if not os.path.exists(config_path): config["CRUPEST_UID"] = str(os.getuid()) config["CRUPEST_GID"] = str(os.getgid()) config["CRUPEST_HALO_DB_PASSWORD"] = os.urandom(8).hex() + config["CRUPEST_IN_CHINA"] = "false" config_content = "" for key in config: config_content += f"{key}={config[key]}\n" @@ -160,4 +161,4 @@ for filename in filenames: with open(os.path.join(project_dir, filename), "w") as f: f.write(content) -print("\n🍻All done! See you next time!") +print("\n🍻All done! See you next time!\nBy the way, you may wish to run tool/download.py to download some scripts to do some extra setup like creating email user.") diff --git a/tool/.gitignore b/tool/.gitignore new file mode 100644 index 0000000..512ee29 --- /dev/null +++ b/tool/.gitignore @@ -0,0 +1 @@ +docker-mailserver-setup.sh
\ No newline at end of file diff --git a/tool/download.py b/tool/download.py new file mode 100755 index 0000000..a77daa1 --- /dev/null +++ b/tool/download.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import os.path + +SCRIPTS = [("docker-mailserver setup script", "docker-mailserver-setup.sh", + "https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master/setup.sh")] + +this_script_dir = os.path.dirname(os.path.relpath(__file__)) + +for script in SCRIPTS: + name, filename, url = script + path = os.path.join(this_script_dir, filename) + skip = False + if os.path.exists(path): + print(f"{name} already exists, download and overwrite? (y/N)", end=" ") + if input() != "y": + skip = True + else: + print(f"Download {name} to {path}? (Y/n)", end=" ") + if input() == "n": + skip = True + if not skip: + print(f"Downloading {name}...") + os.system(f"curl -s {url} > {path} && chmod +x {path}") + print(f"Downloaded {name} to {path}.") + else: + print(f"Skipped {name}.") |