Docker: Fix installation, remove pip, simplify sshd

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-06-27 06:26:18 -07:00
parent 12911a101e
commit acc100eb52
2 changed files with 13 additions and 23 deletions

View file

@ -18,7 +18,7 @@ RUN pacman -Syu --noconfirm --noprogressbar \
python-pytest-asyncio python-coverage hypercorn python-bcrypt \ python-pytest-asyncio python-coverage hypercorn python-bcrypt \
python-email-validator openssh python-lxml mariadb mariadb-libs \ python-email-validator openssh python-lxml mariadb mariadb-libs \
python-isort flake8 cgit uwsgi uwsgi-plugin-cgi php php-fpm \ python-isort flake8 cgit uwsgi uwsgi-plugin-cgi php php-fpm \
python-asgiref uvicorn python-pip python-wheel python-asgiref uvicorn
RUN useradd -U -d /aurweb -c 'AUR User' aur RUN useradd -U -d /aurweb -c 'AUR User' aur
@ -28,8 +28,4 @@ WORKDIR /aurweb
COPY . . COPY . .
RUN make -C po all install RUN make -C po all install
RUN pip3 install -t /aurweb/app --upgrade -I . RUN python3 setup.py install --install-scripts=/usr/local/bin
# Set permissions on directories and binaries.
RUN bash -c 'find /aurweb/app -type d -exec chmod 755 {} \;'
RUN chmod 755 /aurweb/app/bin/*

View file

@ -2,7 +2,7 @@
set -eou pipefail set -eou pipefail
SSHD_CONFIG=/etc/ssh/sshd_config SSHD_CONFIG=/etc/ssh/sshd_config
AUTH_SCRIPT=/aurweb/app/git-auth.sh AUTH_SCRIPT=/app/git-auth.sh
GIT_REPO=/aurweb/aur.git GIT_REPO=/aurweb/aur.git
GIT_BRANCH=master # 'Master' branch. GIT_BRANCH=master # 'Master' branch.
@ -10,7 +10,7 @@ GIT_BRANCH=master # 'Master' branch.
if ! grep -q 'PYTHONPATH' /etc/environment; then if ! grep -q 'PYTHONPATH' /etc/environment; then
echo "PYTHONPATH='/aurweb:/aurweb/app'" >> /etc/environment echo "PYTHONPATH='/aurweb:/aurweb/app'" >> /etc/environment
else else
sed -ri "s|^(PYTHONPATH)=.*$|\1='/aurweb:/aurweb/app'|" /etc/environment sed -ri "s|^(PYTHONPATH)=.*$|\1='/aurweb'|" /etc/environment
fi fi
if ! grep -q 'AUR_CONFIG' /etc/environment; then if ! grep -q 'AUR_CONFIG' /etc/environment; then
@ -19,9 +19,15 @@ else
sed -ri "s|^(AUR_CONFIG)=.*$|\1='/aurweb/conf/config'|" /etc/environment sed -ri "s|^(AUR_CONFIG)=.*$|\1='/aurweb/conf/config'|" /etc/environment
fi fi
if ! grep -q '/aurweb/app/bin' /etc/environment; then mkdir -p /app
echo "PATH='/aurweb/app/bin:\${PATH}'" >> /etc/environment chmod 755 /app
fi
cat >> $AUTH_SCRIPT << EOF
#!/usr/bin/env bash
export AUR_CONFIG="$AUR_CONFIG"
exec /usr/local/bin/aurweb-git-auth "\$@"
EOF
chmod 755 $AUTH_SCRIPT
# Add AUR SSH config. # Add AUR SSH config.
cat >> $SSHD_CONFIG << EOF cat >> $SSHD_CONFIG << EOF
@ -32,16 +38,6 @@ Match User aur
AcceptEnv AUR_OVERWRITE AcceptEnv AUR_OVERWRITE
EOF EOF
cat >> $AUTH_SCRIPT << EOF
#!/usr/bin/env bash
export PYTHONPATH="$PYTHONPATH"
export AUR_CONFIG="$AUR_CONFIG"
export PATH="/aurweb/app/bin:\${PATH}"
exec /aurweb/app/bin/aurweb-git-auth "\$@"
EOF
chmod 755 $AUTH_SCRIPT
DB_NAME="aurweb" DB_NAME="aurweb"
DB_HOST="mariadb" DB_HOST="mariadb"
DB_USER="aur" DB_USER="aur"
@ -54,7 +50,6 @@ sed -ri "s/^(name) = .+/\1 = ${DB_NAME}/" $AUR_CONFIG
sed -ri "s/^(host) = .+/\1 = ${DB_HOST}/" $AUR_CONFIG sed -ri "s/^(host) = .+/\1 = ${DB_HOST}/" $AUR_CONFIG
sed -ri "s/^(user) = .+/\1 = ${DB_USER}/" $AUR_CONFIG sed -ri "s/^(user) = .+/\1 = ${DB_USER}/" $AUR_CONFIG
sed -ri "s/^;?(password) = .+/\1 = ${DB_PASS}/" $AUR_CONFIG sed -ri "s/^;?(password) = .+/\1 = ${DB_PASS}/" $AUR_CONFIG
sed -i "s|/usr/local/bin|/aurweb/app/bin|g" $AUR_CONFIG
AUR_CONFIG_DEFAULTS="${AUR_CONFIG}.defaults" AUR_CONFIG_DEFAULTS="${AUR_CONFIG}.defaults"
@ -63,7 +58,6 @@ if [[ "$AUR_CONFIG_DEFAULTS" != "/aurweb/conf/config.defaults" ]]; then
fi fi
# Set some defaults needed for pathing and ssh uris. # Set some defaults needed for pathing and ssh uris.
sed -i "s|/usr/local/bin|/aurweb/app/bin|g" $AUR_CONFIG_DEFAULTS
sed -ri "s|^(repo-path) = .+|\1 = /aurweb/aur.git/|" $AUR_CONFIG_DEFAULTS sed -ri "s|^(repo-path) = .+|\1 = /aurweb/aur.git/|" $AUR_CONFIG_DEFAULTS
ssh_cmdline='ssh ssh://aur@localhost:2222' ssh_cmdline='ssh ssh://aur@localhost:2222'