Merge pull request #2920 from laradock/reorganize-change-source

feat(change source): move together
This commit is contained in:
Shao Yu-Lung (Allen) 2021-03-24 00:38:24 +08:00 committed by GitHub
commit d7a52d56be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,19 +23,26 @@ ARG LARADOCK_PHP_VERSION
# Set Environment Variables
ENV DEBIAN_FRONTEND noninteractive
# If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
ARG CHANGE_SOURCE=false
RUN if [ ${CHANGE_SOURCE} = true ]; then \
# Change application source from deb.debian.org to aliyun source
sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && \
sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && \
sed -i 's/security-cdn.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list \
;fi
# Start as root
USER root
###########################################################################
# If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
###########################################################################
ARG CHANGE_SOURCE=false
ARG UBUNTU_SOURCE=aliyun
COPY ./sources.sh /tmp/sources.sh
RUN if [ ${CHANGE_SOURCE} = true ]; then \
# Change application source from deb.debian.org to aliyun source
sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list; \
sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list; \
sed -i 's/security-cdn.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list; \
chmod +x /tmp/sources.sh; \
/bin/sh -c /tmp/sources.sh; \
fi; \
rm -rf /tmp/sources.sh
###########################################################################
# Laradock non-root user:
###########################################################################
@ -46,16 +53,6 @@ ENV PUID ${PUID}
ARG PGID=1000
ENV PGID ${PGID}
ARG CHANGE_SOURCE=false
ARG UBUNTU_SOURCE
COPY ./sources.sh /tmp/sources.sh
RUN if [ ${CHANGE_SOURCE} = true ]; then \
chmod +x /tmp/sources.sh && \
/bin/sh -c /tmp/sources.sh && \
rm -rf /tmp/sources.sh \
;fi
# always run apt update when start and after add new source list, then clean up at end.
RUN set -xe; \
apt-get update -yqq && \