Skip to content

Commit

Permalink
feat: adopt modern Dockerfile (#122)
Browse files Browse the repository at this point in the history
* feat: adopt modern Dockerfile

Signed-off-by: Jian Zeng <[email protected]>

* fix(debian): RUN command with bash

Signed-off-by: Jian Zeng <[email protected]>

* refactor: prepare.sh is not needed anymore

Signed-off-by: Jian Zeng <[email protected]>

---------

Signed-off-by: Jian Zeng <[email protected]>
  • Loading branch information
knight42 authored Aug 13, 2024
1 parent df02b49 commit cf8884e
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 104 deletions.
5 changes: 4 additions & 1 deletion apt-sync/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM ustcmirror/base:alpine
LABEL maintainer="iBug <[email protected]>"
LABEL bind_support=true
RUN apk add --no-cache --update wget perl ca-certificates git python3 py3-requests && \
RUN <<EOF
set -euo pipefail
apk add --no-cache --update wget perl ca-certificates git python3 py3-requests
mkdir -p /usr/local/lib/tunasync
EOF
ADD tunasync /usr/local/lib/tunasync
ADD sync.sh sync.py /
8 changes: 5 additions & 3 deletions aptsync/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ LABEL bind_support=true
ENV APTSYNC_NTHREADS=20 \
APTSYNC_CREATE_DIR=true \
APTSYNC_UNLINK=0
RUN apk add --no-cache --update wget perl ca-certificates xz \
&& mkdir -p /var/spool/apt-mirror/mirror /var/spool/apt-mirror/skel /etc/apt/
RUN <<EOF
set -euo pipefail
apk add --no-cache --update wget perl ca-certificates xz
mkdir -p /var/spool/apt-mirror/mirror /var/spool/apt-mirror/skel /etc/apt/
EOF
ADD ["apt-mirror", "/usr/local/bin/apt-mirror"]
RUN chmod +x /usr/local/bin/apt-mirror
ADD ["pre-sync.sh", "sync.sh", "/"]
Empty file modified aptsync/apt-mirror
100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion base/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM alpine:3.20
LABEL maintainer="Jian Zeng <anonymousknight96 AT gmail.com>" \
org.ustcmirror.images=true
RUN apk add --no-cache bash tzdata su-exec && \
RUN <<EOF
set -euo pipefail
apk add --no-cache bash tzdata su-exec
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EOF
ADD ["entry.sh", "savelog", "/usr/local/bin/"]
ADD ["pip.conf", "/etc/"]
VOLUME ["/data", "/log"]
Expand Down
5 changes: 4 additions & 1 deletion base/Dockerfile.alpine-edge
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM alpine:edge
LABEL maintainer="Yifan Gao<git AT yfgao.com>" \
org.ustcmirror.images=true
RUN apk add --no-cache bash tzdata su-exec && \
RUN <<EOF
set -euo pipefail
apk add --no-cache bash tzdata su-exec
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EOF
ADD ["entry.sh", "savelog", "/usr/local/bin/"]
VOLUME ["/data", "/log"]
CMD ["entry.sh"]
18 changes: 13 additions & 5 deletions base/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
FROM debian:bookworm-slim
LABEL maintainer="Jian Zeng <anonymousknight96 AT gmail.com>" \
org.ustcmirror.images=true
RUN echo 'Asia/Shanghai' > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata && \
apt-get update && apt-get install -y wget && \
wget -O /usr/local/bin/su-exec https://ftp.lug.ustc.edu.cn/misc/su-exec && chmod +x /usr/local/bin/su-exec && \
echo "592f25c51d0e4c90945ece8c4fa35018d20a1091ac109c98b66eb95deef211c7 /usr/local/bin/su-exec" | sha256sum -c - && \
apt-get purge -y --auto-remove wget && rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,sharing=locked,target=/var/lib/apt <<EOF
#!/bin/bash

set -euo pipefail
echo 'Asia/Shanghai' > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
apt-get update && apt-get install -y wget
wget -O /usr/local/bin/su-exec https://ftp.lug.ustc.edu.cn/misc/su-exec
chmod +x /usr/local/bin/su-exec
echo "592f25c51d0e4c90945ece8c4fa35018d20a1091ac109c98b66eb95deef211c7 /usr/local/bin/su-exec" | sha256sum -c -
apt-get purge -y --auto-remove wget
EOF
ADD ["entry.sh", "savelog", "/usr/local/bin/"]
VOLUME ["/data", "/log"]
CMD ["entry.sh"]
13 changes: 11 additions & 2 deletions debian-cd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ FROM ustcmirror/base:alpine
LABEL maintainer="Jian Zeng <anonymousknight96 AT gmail.com>"
LABEL bind_support=true
VOLUME ["/debian"]
ADD ["sync.sh", "pre-sync.sh", "prepare.sh", "/"]
ADD ["sync.sh", "pre-sync.sh", "/"]
ADD ["jigdo-mirror", "cd-mirror", "/usr/local/bin/"]
ADD jigdo-mirror.conf.in /etc/jigdo/
RUN /prepare.sh && rm /prepare.sh
RUN <<EOF
set -euo pipefail
apk add --no-cache wget ca-certificates rsync
mkdir -p /etc/jigdo
wget 'https://ftp.lug.ustc.edu.cn/misc/jigdo-bin-0.7.3.tar.bz2'
echo "58b8a6885822e55f365c99131c906f16ceaaf657c566e10f410d026704cad157 jigdo-bin-0.7.3.tar.bz2" | sha256sum -c -
tar xf jigdo-bin-0.7.3.tar.bz2 jigdo-bin-0.7.3/jigdo-file
mv jigdo-bin-0.7.3/jigdo-file /usr/local/bin/
rm -rf jigdo-bin-*
EOF
9 changes: 0 additions & 9 deletions debian-cd/prepare.sh

This file was deleted.

8 changes: 5 additions & 3 deletions docker-ce/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM ustcmirror/base:alpine
LABEL maintainer="Keyu Tao <[email protected]>"
RUN apk add --no-cache --update wget perl ca-certificates git python3 py3-requests py3-pip py3-lxml && \
pip3 install pyquery && \
mkdir -p /usr/local/lib/tunasync
RUN <<EOF
set -euo pipefail
apk add --no-cache --update wget perl ca-certificates git python3 py3-requests py3-pip py3-lxml
pip3 install pyquery
EOF
ADD tunasync /usr/local/lib/tunasync
ADD sync.sh /
9 changes: 6 additions & 3 deletions fedora/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM ustcmirror/base:alpine
LABEL maintainer="Shengjing Zhu <[email protected]>"
LABEL bind_support=true
RUN apk add --no-cache zsh curl rsync ca-certificates gawk grep bzip2 coreutils diffutils findutils \
&& curl -fLo /usr/local/bin/quick-fedora-mirror https://pagure.io/quick-fedora-mirror/raw/master/f/quick-fedora-mirror \
&& chmod +x /usr/local/bin/quick-fedora-mirror
RUN <<EOF
set -euo pipefail
apk add --no-cache zsh curl rsync ca-certificates gawk grep bzip2 coreutils diffutils findutils
curl -fLo /usr/local/bin/quick-fedora-mirror https://pagure.io/quick-fedora-mirror/raw/master/f/quick-fedora-mirror
chmod +x /usr/local/bin/quick-fedora-mirror
EOF
ADD ["pre-sync.sh", "sync.sh", "/"]
22 changes: 20 additions & 2 deletions ghcup/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
FROM ustcmirror/base:debian
LABEL maintainer="Kai Ma <[email protected]>"
ADD ["sync.sh", "prepare.sh", "ghcupsync.hs", "/"]
RUN bash /prepare.sh && rm prepare.sh
ADD ["sync.sh", "ghcupsync.hs", "/"]
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,sharing=locked,target=/var/lib/apt <<EOF
#!/bin/bash

HASKELL_DEPS="ghc libghc-aeson-dev libghc-lens-dev libghc-lens-aeson-dev \
libghc-network-uri-dev libghc-split-dev libghc-typed-process-dev \
libghc-yaml-dev"
# Please use ldd to check the dependencies of compiled binary
HASKELL_KEEP="libyaml-0-2"

apt-get update
apt-get install -y aria2 ca-certificates git curl $HASKELL_DEPS $HASKELL_KEEP

# compile with Haskell language extensions
ghc -O2 -XScopedTypeVariables -XOverloadedStrings ghcupsync.hs

rm -rf /ghcupsync.* && apt-get purge -y --auto-remove $HASKELL_DEPS

EOF
16 changes: 0 additions & 16 deletions ghcup/prepare.sh

This file was deleted.

3 changes: 1 addition & 2 deletions github-release/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM ustcmirror/base:alpine
LABEL maintainer="Yulong Ming <[email protected]>"
LABEL bind_support=true
RUN apk add --no-cache python3 py3-requests py3-yaml && \
mkdir -p /usr/local/lib/tunasync
RUN apk add --no-cache python3 py3-requests py3-yaml
ADD tunasync /usr/local/lib/tunasync
ADD sync.sh /
7 changes: 5 additions & 2 deletions google-repo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM ustcmirror/base:alpine
LABEL maintainer="Keyu Tao <taoky AT lug.ustc.edu.cn>"
RUN apk add --no-cache git curl python3 openssh-client gnupg && \
curl -fLo /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo && \
RUN <<EOF
set -euo pipefail
apk add --no-cache git curl python3 openssh-client gnupg
curl -fLo /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo
chmod +x /usr/local/bin/repo
EOF
ADD ["pre-sync.sh", "sync.sh", "/"]
9 changes: 5 additions & 4 deletions gsutil-rsync/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM ustcmirror/base:alpine
LABEL maintainer="Yao Wei (魏銘廷) <[email protected]>"

RUN apk add --no-cache python3 py-setuptools openssl libffi && \
apk add --no-cache --virtual .build-deps gcc musl-dev python3-dev py3-pip openssl-dev libffi-dev && \
pip3 install --upgrade pip && \
RUN <<EOF
set -euo pipefail
apk add --no-cache python3 py-setuptools openssl libffi py3-pip
pip3 install --upgrade pip
pip3 --no-cache-dir install gsutil

EOF
ADD pre-sync.sh sync.sh /
13 changes: 8 additions & 5 deletions julia-storage/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
FROM ustcmirror/base:alpine

ENV JULIA_DEPOT_PATH="/opt/julia/depot"
RUN apk update && apk add --no-cache curl python3 gnupg py3-pip && \
pip3 install jill && jill install 1.5 --confirm && \
ln -s /opt/julias/julia-1.5 /opt/julia && \
julia -e 'using Pkg; pkg"add [email protected]"' && \
chmod a+rx -R $JULIA_DEPOT_PATH
RUN <<EOF
apk update
apk add --no-cache curl python3 gnupg py3-pip
pip3 install jill && jill install 1.5 --confirm
ln -s /opt/julias/julia-1.5 /opt/julia
julia -e 'using Pkg; pkg"add [email protected]"'
chmod a+rx -R $JULIA_DEPOT_PATH
EOF

ADD startup.jl /opt/julia/etc/julia/startup.jl
ADD ["pre-sync.sh", "sync.sh", "/"]
20 changes: 11 additions & 9 deletions nix-channels/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
FROM ustcmirror/base:alpine

RUN \
RUN <<EOF
set -euo pipefail
# Install Nix. To simplify management we only copy binaries and create
# symlinks, and do no further configuration
wget https://nixos.org/releases/nix/nix-2.3.2/nix-2.3.2-x86_64-linux.tar.xz -O /tmp/nix.tar.xz && \
mkdir /tmp/nix.unpack && \
tar xpf /tmp/nix.tar.xz -C /tmp/nix.unpack && \
mkdir /nix && \
cp -dpr /tmp/nix.unpack/*/store /nix/store && \
ln -s /nix/store/*-nix-*/bin/* /usr/local/bin && \
rm -rf /tmp/nix.tar.xz /tmp/nix.unpack && \
wget https://nixos.org/releases/nix/nix-2.3.2/nix-2.3.2-x86_64-linux.tar.xz -O /tmp/nix.tar.xz
mkdir /tmp/nix.unpack
tar xpf /tmp/nix.tar.xz -C /tmp/nix.unpack
mkdir /nix
cp -dpr /tmp/nix.unpack/*/store /nix/store
ln -s /nix/store/*-nix-*/bin/* /usr/local/bin
rm -rf /tmp/nix.tar.xz /tmp/nix.unpack
# ca-certificates required by nix
apk add --no-cache ca-certificates python3 py3-requests py3-pip py3-lxml py3-tz && \
apk add --no-cache ca-certificates python3 py3-requests py3-pip py3-lxml py3-tz
pip3 install pyquery minio==6.0.2
EOF

ADD [ "sync.sh", "nix-channels.py", "/" ]
7 changes: 5 additions & 2 deletions pypi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ ENV PYPI_MASTER=https://pypi.python.org \
BANDERSNATCH_WORKERS=3 \
BANDERSNATCH_STOP_ON_ERROR=true \
BANDERSNATCH_TIMEOUT=20
RUN apk add --no-cache python3 python3-dev py3-pip musl-dev gcc libxml2 libxslt libxml2-dev libxslt-dev && \
pip3 --no-cache-dir install bandersnatch && \
RUN <<EOF
set -euo pipefail
apk add --no-cache python3 python3-dev py3-pip musl-dev gcc libxml2 libxslt libxml2-dev libxslt-dev
pip3 --no-cache-dir install bandersnatch
apk del --purge python3-dev musl-dev gcc libxml2-dev libxslt-dev
EOF
ADD sync.sh pre-sync.sh /
11 changes: 7 additions & 4 deletions rclone/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ ARG RCLONE_VERSION=v1.50.2
ENV RCLONE_DELETE_AFTER=true \
RCLONE_DELETE_EXCLUDED=true

RUN apk add --no-cache wget ca-certificates && \
cd /tmp/ && wget -q "https://downloads.rclone.org/$RCLONE_VERSION/rclone-$RCLONE_VERSION-linux-amd64.zip" && \
unzip /tmp/rclone*.zip && \
mv /tmp/rclone-*/rclone /usr/local/bin/ && \
RUN <<EOF
set -euo pipefail
apk add --no-cache wget ca-certificates
cd /tmp/ && wget -q "https://downloads.rclone.org/$RCLONE_VERSION/rclone-$RCLONE_VERSION-linux-amd64.zip"
unzip /tmp/rclone*.zip
mv /tmp/rclone-*/rclone /usr/local/bin/
rm -rf /tmp/* && apk del wget
EOF

ADD sync.sh /
11 changes: 7 additions & 4 deletions shadowmire/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ FROM ustcmirror/base:alpine
LABEL maintainer="Keyu Tao <taoky AT ustclug.org>"
ARG COMMIT=0a6a958e49ed1ce287596f04414fc21faf4ffac8

RUN apk add --no-cache wget ca-certificates python3 py3-click py3-requests py3-tqdm && \
cd /tmp/ && wget -q "https://raw.githubusercontent.com/taoky/shadowmire/$COMMIT/shadowmire.py" && \
mv /tmp/shadowmire.py /usr/local/bin/shadowmire && \
chmod +x /usr/local/bin/shadowmire && \
RUN <<EOF
set -euo pipefail
apk add --no-cache wget ca-certificates python3 py3-click py3-requests py3-tqdm
cd /tmp/ && wget -q "https://raw.githubusercontent.com/taoky/shadowmire/$COMMIT/shadowmire.py"
mv /tmp/shadowmire.py /usr/local/bin/shadowmire
chmod +x /usr/local/bin/shadowmire
rm -rf /tmp/* && apk del wget
EOF

ADD sync.sh /
19 changes: 17 additions & 2 deletions stackage/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
FROM ustcmirror/base:debian
LABEL maintainer="Jiahao Li <[email protected]>"
LABEL maintainer="Keyu Tao <[email protected]>"
ADD ["sync.sh", "prepare.sh", "stackage.hs", "/"]
RUN bash /prepare.sh && rm prepare.sh
ADD ["sync.sh", "stackage.hs", "/"]
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,sharing=locked,target=/var/lib/apt <<EOF
#!/bin/bash

HASKELL_DEPS="ghc libghc-yaml-dev libghc-process-extras-dev \
libghc-aeson-dev libghc-split-dev"
# Please use ldd to check the dependencies of compiled binary
HASKELL_KEEP="libyaml-0-2"

apt-get update
apt-get install -y aria2 ca-certificates git $HASKELL_DEPS $HASKELL_KEEP
ghc -O2 stackage.hs

rm -rf stackage.* && apt-get purge --auto-remove -y $HASKELL_DEPS

EOF
13 changes: 0 additions & 13 deletions stackage/prepare.sh

This file was deleted.

11 changes: 7 additions & 4 deletions tsumugu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ LABEL maintainer="Keyu Tao <taoky AT ustclug.org>"
LABEL bind_support=true
ARG TSUMUGU_VERSION=20240811

RUN apk add --no-cache wget ca-certificates && \
cd /tmp/ && wget -q "https://github.com/taoky/tsumugu/releases/download/${TSUMUGU_VERSION}/tsumugu" && \
mv /tmp/tsumugu /usr/local/bin/ && \
chmod +x /usr/local/bin/tsumugu && \
RUN <<EOF
set -euo pipefail
apk add --no-cache wget ca-certificates
cd /tmp/ && wget -q "https://github.com/taoky/tsumugu/releases/download/${TSUMUGU_VERSION}/tsumugu"
mv /tmp/tsumugu /usr/local/bin/
chmod +x /usr/local/bin/tsumugu
rm -rf /tmp/* && apk del wget
EOF

ADD sync.sh /
10 changes: 7 additions & 3 deletions winget-source/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ LABEL bind_support=true
RUN apk add --no-cache nodejs

ADD ["package.json", "package-lock.json", "/"]
RUN apk add --no-cache npm python3 && \
npm ci --prefix / --only=production && \
npm cache clean --force && \
RUN <<EOF
set -euo pipefail
apk add --no-cache npm python3
npm ci --prefix / --only=production
npm cache clean --force
apk del --purge --no-cache npm python3
EOF
RUN

ADD ["sync.sh", "sync-repo.js", "sysexits.js", "utilities.js", "/"]
11 changes: 7 additions & 4 deletions yukina/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ LABEL maintainer="Keyu Tao <taoky AT ustclug.org>"
LABEL bind_support=true
ARG YUKINA_VERSION=20240811

RUN apk add --no-cache wget ca-certificates zstd && \
cd /tmp/ && wget -q "https://github.com/taoky/yukina/releases/download/${YUKINA_VERSION}/yukina" && \
mv /tmp/yukina /usr/local/bin/ && \
chmod +x /usr/local/bin/yukina && \
RUN <<EOF
set -euo pipefail
apk add --no-cache wget ca-certificates zstd
cd /tmp/ && wget -q "https://github.com/taoky/yukina/releases/download/${YUKINA_VERSION}/yukina"
mv /tmp/yukina /usr/local/bin/
chmod +x /usr/local/bin/yukina
rm -rf /tmp/* && apk del wget
EOF

ADD sync.sh /

0 comments on commit cf8884e

Please sign in to comment.