Skip to content

Commit

Permalink
[feat] nginx dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
telanflow committed Dec 29, 2021
1 parent 57cb31e commit cc3acda
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
34 changes: 34 additions & 0 deletions build/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 ;
4 changes: 4 additions & 0 deletions build/nginx/resource/sources.list
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit cc3acda

Please sign in to comment.