File size: 1,205 Bytes
f694e8f
 
aa3864c
 
f694e8f
 
 
 
24f0332
f694e8f
978bce4
3e21c67
b33c53d
aa3864c
f694e8f
 
 
27b1986
978bce4
 
3e21c67
 
978bce4
37fbd48
 
 
 
 
b4d7b3e
978bce4
37fbd48
 
978bce4
 
24f0332
 
2688bd3
6712450
730aedf
748ce07
37fbd48
2688bd3
37fbd48
b04a8cc
978bce4
f694e8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#first dockerfile

#FROM nginx:latest
FROM ubuntu:latest
# RUN apt-get update
# RUN apt-get install -y vim 

# RUN apt-get install -y nginx

# 以上执行会创建 3 层镜像。可简化为以下格式:


ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y vim &&  apt-get install -y nginx
# 如上,以 && 符号连接命令,这样执行后,只会创建 1 层镜像。
#指定运行该镜像的容器使用的端口为 80
# docker run的时候 一定要加上 -P
EXPOSE 7860


RUN chown -R 1000 /var/log/nginx/ /var/lib/nginx/ /run/ 
RUN useradd -m -u 1000 user
USER user
ENV HOME  /home/user

#RUN useradd -m -u 1000 user
# Switch to the "user" user
#USER user

# Set home to the user's home directory
#ENV HOME=/home/user \
#PATH=/home/user/.local/bin:$PATH
# Set the working directory to the user's home directory
WORKDIR $HOME
#RUN mkdir /usr/share/nginx/html/app
#RUN chown user /usr/share/nginx/html/app
COPY --chown=user:user . /home/user/app
COPY . /var/www/html/

#RUN chown -R 1000 /home/user

#COPY --chown=user:user ./app /home/user/app
COPY ./default /etc/nginx/sites-available
#COPY --chown=user:user ./htpasswd /etc/nginx

CMD ["nginx","-g","daemon off;"]