From cc3acda2268519e22785cb22d6554e954baaf714 Mon Sep 17 00:00:00 2001 From: telanflow Date: Wed, 29 Dec 2021 10:04:02 +0800 Subject: [PATCH] [feat] nginx dockerfile --- build/nginx/Dockerfile | 34 +++++++++++++++++++++++++++++++ build/nginx/resource/sources.list | 4 ++++ docker-compose.yml | 6 +++++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 build/nginx/Dockerfile create mode 100755 build/nginx/resource/sources.list diff --git a/build/nginx/Dockerfile b/build/nginx/Dockerfile new file mode 100644 index 0000000..97d40a0 --- /dev/null +++ b/build/nginx/Dockerfile @@ -0,0 +1,34 @@ +FROM nginx:latest + +COPY resource /home/resource + +ARG CHANGE_SOURCE=true +ARG TIME_ZONE=UTC + +ENV TIME_ZONE=${TIME_ZONE} LC_ALL=C.UTF-8 + +RUN \ + # ⬇ 修改时区 + ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime ; \ + echo $TIME_ZONE > /etc/timezone ; \ + \ + # ⬇ 替换源 + rm -rf /etc/apt/sources.list.d/buster.list ; \ + if [ ${CHANGE_SOURCE} = true ]; then \ + mv /etc/apt/sources.list /etc/apt/source.list.bak ; \ + mv /home/resource/sources.list /etc/apt/sources.list ; \ + fi; \ + \ + # ⬇ 更新、安装基础组件 + apt-get update && apt-get install -y --no-install-recommends \ + # tools + wget \ + zip \ + unzip \ + git \ + cron \ + vim \ + iputils-ping \ + telnet \ + net-tools \ + ntpdate ; diff --git a/build/nginx/resource/sources.list b/build/nginx/resource/sources.list new file mode 100755 index 0000000..453a7e1 --- /dev/null +++ b/build/nginx/resource/sources.list @@ -0,0 +1,4 @@ +deb http://mirrors.aliyun.com/debian/ buster main non-free contrib +deb http://mirrors.aliyun.com/debian-security buster/updates main +deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib +deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 96d40f4..e4cce41 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,11 @@ services: ### Nginx container ######################################### nginx: container_name: dnmp-nginx - image: nginx:latest + build: + context: ./build/nginx + args: + TIME_ZONE: ${GLOBAL_TIME_ZONE} + CHANGE_SOURCE: ${GLOBAL_CHANGE_SOURCE} ports: - "${HTTP_PORT}:80" - "${HTTPS_PORT}:443"