From 0e5977cc64168d60cecc4bb975aeac50dea60869 Mon Sep 17 00:00:00 2001 From: Shao Yu Lung Date: Tue, 23 Mar 2021 23:03:56 +0800 Subject: [PATCH] feat(change source): move together --- workspace/Dockerfile | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 9727078..ca62496 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -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 && \