aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/arch-code-server/Dockerfile25
-rwxr-xr-xdocker/arch-code-server/archlinux-setup-user.bash35
-rwxr-xr-xdocker/arch-code-server/archlinux-setup.bash61
-rwxr-xr-xdocker/arch-code-server/china-magic-for-pkgbuild.py21
-rwxr-xr-xdocker/arch-code-server/restore-pacman-conf.py47
-rw-r--r--docker/crupest-nginx/Dockerfile2
6 files changed, 5 insertions, 186 deletions
diff --git a/docker/arch-code-server/Dockerfile b/docker/arch-code-server/Dockerfile
index 6471fac..fe810cd 100644
--- a/docker/arch-code-server/Dockerfile
+++ b/docker/arch-code-server/Dockerfile
@@ -1,25 +1,8 @@
-FROM archlinux:latest
+FROM alpine:latest
-ARG CRUPEST_USER
-ARG CRUPEST_GROUP
-ARG CRUPEST_UID=1000
-ARG CRUPEST_GID=1000
-ARG CRUPEST_PACKAGES=""
-ARG CRUPEST_AUR_PACKAGES=""
-ARG USE_CHINA_MIRROR="false"
-ARG CHINA_MIRROR_URL="https://mirrors.ustc.edu.cn/archlinux/\$repo/os/\$arch"
-
-ADD ./archlinux-setup.bash ./archlinux-setup-user.bash ./china-magic-for-pkgbuild.py ./restore-pacman-conf.py /tmp/
-
-ENV CRUPEST_IN_DOCKER="true"
-WORKDIR /tmp
-RUN /tmp/archlinux-setup.bash
-USER ${CRUPEST_UID}:${CRUPEST_GID}
-WORKDIR /home/${CRUPEST_USER}
-RUN /tmp/archlinux-setup-user.bash
-
-VOLUME [ "/data" ]
+RUN apk add --no-cache alpine-sdk bash libstdc++ libc6-compat && npm config set python python3 && npm install --global code-server --unsafe-perm
+WORKDIR /root
EXPOSE 8080
-
+VOLUME [ "/data" ]
ENV CODE_SERVER_CONFIG="/data/code-server-config.yaml"
ENTRYPOINT [ "code-server", "--bind-addr", "0.0.0.0:8080" ]
diff --git a/docker/arch-code-server/archlinux-setup-user.bash b/docker/arch-code-server/archlinux-setup-user.bash
deleted file mode 100755
index 6b30b28..0000000
--- a/docker/arch-code-server/archlinux-setup-user.bash
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-
-# check if we are in docker by CRUPEST_IN_DOCKER
-if [ "${CRUPEST_IN_DOCKER}" != "true" ]; then
- echo "This script is intended to be run in a docker container."
- exit 1
-fi
-
-# don't allow any error
-set -e
-
-cd ~
-
-mkdir aur
-cd aur
-
-# install all aur packages
-for aur_package in code-server ${CRUPEST_AUR_PACKAGES} ; do
- echo "Installing ${aur_package} from AUR..."
- git clone "https://aur.archlinux.org/${aur_package}.git" --depth 1
- pushd "${aur_package}"
-
- # do some magic thing for China
- if [ "${USE_CHINA_MIRROR}" = "true" ]; then
- mv PKGBUILD PKGBUILD.old
- /tmp/china-magic-for-pkgbuild.py < PKGBUILD.old > PKGBUILD
- fi
-
- makepkg -sr --noconfirm
- makepkg --packagelist | sudo pacman -U --noconfirm -
- popd
-done
-
-# finnally, test code-server
-code-server --version
diff --git a/docker/arch-code-server/archlinux-setup.bash b/docker/arch-code-server/archlinux-setup.bash
deleted file mode 100755
index c926384..0000000
--- a/docker/arch-code-server/archlinux-setup.bash
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env bash
-
-# check if we are in docker by CRUPEST_IN_DOCKER
-if [ "${CRUPEST_IN_DOCKER}" != "true" ]; then
- echo "This script is intended to be run in a docker container."
- exit 1
-fi
-
-# check if we are root
-if [ "$(id -u)" != "0" ]; then
- echo "This script must be run as root."
- exit 1
-fi
-
-# CRUPEST_USER, CRUPEST_UID, CRUPEST_GID must be defined
-if [ -z "$CRUPEST_USER" ] || [ -z "$CRUPEST_UID" ] || [ -z "$CRUPEST_GID" ]; then
- echo "CRUPEST_USER, CRUPEST_UID, CRUPEST_GID must be defined."
- exit 1
-fi
-
-# if we are in China (by checking USE_CHINA_MIRROR), use the mirror in China
-if [ "$USE_CHINA_MIRROR" = "true" ]; then
- echo "You have set USE_CHINA_MIRROR to true, using mirror ${CHINA_MIRROR_URL} (set by CHINA_MIRROR_URL) in China."
- echo "Server = ${CHINA_MIRROR_URL}" > /etc/pacman.d/mirrorlist
-fi
-
-# from now on, we don't allow error
-set -e
-
-# Update the system and I need python3
-pacman -Syu --noconfirm python
-
-# execute the restore pacman config script
-python3 ./restore-pacman-conf.py
-
-# reinstall all installed packages
-pacman -Qnq | pacman -S --noconfirm --overwrite=* -
-
-# install new packages
-echo "base-devel git ${CRUPEST_PACKAGES}" | tr " " "\n" | pacman -S --noconfirm --needed -
-
-# if GROUP not defined, set it the same to USER
-if [ -z "$CRUPEST_GROUP" ]; then
- CRUPEST_GROUP="$CRUPEST_USER"
-fi
-
-# check if GROUP exists. if not create it with GID
-if ! grep -q "^${CRUPEST_GROUP}:" /etc/group; then
- groupadd -g "$CRUPEST_GID" "$CRUPEST_GROUP"
-fi
-
-# create user for UID and GID
-useradd -m -u "${CRUPEST_UID}" -g "${CRUPEST_GID}" "${CRUPEST_USER}"
-
-# add the user to sudo
-echo "${CRUPEST_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
-
-# create data directory and change the permission
-mkdir -p /data
-chown "${CRUPEST_USER}":"${CRUPEST_GROUP}" /data
-chmod 700 /data
diff --git a/docker/arch-code-server/china-magic-for-pkgbuild.py b/docker/arch-code-server/china-magic-for-pkgbuild.py
deleted file mode 100755
index 43a4d89..0000000
--- a/docker/arch-code-server/china-magic-for-pkgbuild.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env python3
-
-# In China? Good for you!
-
-import sys
-import re
-
-# read STDIN until EOF
-content = sys.stdin.read()
-
-url = re.search(r"url=(.+)", content).group(1)
-if url.startswith('"') and url.endswith('"'):
- url = url[1:-1]
-
-if url.startswith("https://github.com"): # yah, it's github!
- content = re.sub(r"\$\{\s*url\s*\}|\$url", url, content)
- content = content.replace("https://raw.githubusercontent.com", "https://gh.api.99988866.xyz/https://raw.githubusercontent.com")
- content = re.sub(r'https://github\.com/(.+)/(.+)/releases/download', lambda match: f'https://gh.api.99988866.xyz/{match.group(0)}', content)
-
-# now print the result
-print(content)
diff --git a/docker/arch-code-server/restore-pacman-conf.py b/docker/arch-code-server/restore-pacman-conf.py
deleted file mode 100755
index 3486dd3..0000000
--- a/docker/arch-code-server/restore-pacman-conf.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python3
-
-# Fxxk damn shit bash script and linux tools. They just don't work well with text processing, which took me a long time to discover the stupid fact.
-
-import os
-import os.path
-import sys
-import urllib.request
-from http.client import HTTPResponse
-
-PACMAN_NO_EXTRACT_URL = 'https://gitlab.archlinux.org/archlinux/archlinux-docker/-/raw/master/pacman-conf.d-noextract.conf'
-
-# check if this is in docker by CRUPEST_IN_DOCKER env
-if not os.environ.get('CRUPEST_IN_DOCKER'):
- print("Not in docker, exiting!", file=sys.stderr)
- exit(1)
-
-# check if I'm root
-if os.geteuid() != 0:
- print("Not root, exiting!", file=sys.stderr)
- exit(1)
-
-# check if pacman.conf exists
-if not os.path.exists('/etc/pacman.conf'):
- print("/etc/pacman.conf does not exist, are you running this in Arch Linux? Exiting!", file=sys.stderr)
- exit(2)
-
-# Download pacman-no-extract file from url
-res: HTTPResponse = urllib.request.urlopen(PACMAN_NO_EXTRACT_URL)
-if res.status != 200:
- print(
- f"Failed to download pacman-no-extract file from url: {PACMAN_NO_EXTRACT_URL}, exiting!", file=sys.stderr)
- exit(3)
-
-# Read the content of pacman-no-extract file
-pacman_no_extract_content = res.read().decode('utf-8')
-
-# Read the content of pacman.conf
-with open('/etc/pacman.conf', 'r') as f:
- pacman_conf_content = f.read()
- # remove pacman_no_extract_content from pacman_conf_content
- pacman_conf_content = pacman_conf_content.replace(
- pacman_no_extract_content, '')
-
-# Write the content of pacman.conf
-with open('/etc/pacman.conf', 'w') as f:
- f.write(pacman_conf_content)
diff --git a/docker/crupest-nginx/Dockerfile b/docker/crupest-nginx/Dockerfile
index cf08ee5..046031b 100644
--- a/docker/crupest-nginx/Dockerfile
+++ b/docker/crupest-nginx/Dockerfile
@@ -12,6 +12,6 @@ RUN git clone https://github.com/crupest/blog.git && cd blog && git submodule up
WORKDIR /blog
RUN hugo
-FROM nginx:latest
+FROM nginx:mainline-alpine
COPY --from=build-www /sites/www/dist /srv/www
COPY --from=build-blog /blog/public /srv/blog