-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.frontend
68 lines (51 loc) · 2.26 KB
/
Dockerfile.frontend
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
FROM nginx:latest
# default to dev environment
ARG ENVIRONMENT=dev
# set domain name
ARG DOC_DOMAIN=multirotor-rate-converter
# set location of nginx config
ARG NGINX_CONF=/etc/nginx/nginx.conf
# copy nginx config
COPY ./nginx.conf $NGINX_CONF
# remove all of the ssl configurations if the environment is dev
RUN if [ "$ENVIRONMENT" = "dev" ]; then \
sed -i '/listen 80 default_server; # ssl default server/d' $NGINX_CONF && \
sed -i '/return 301 https:\/\/$host$request_uri;/d' $NGINX_CONF && \
sed -i '/listen 443 ssl;/d' $NGINX_CONF && \
sed -i '/listen \[::\]:443 ssl ipv6only=on;/d' $NGINX_CONF && \
sed -i '/ssl_certificate \/etc\/nginx\/ssl\/${DOC_DOMAIN}\/domain.cert.pem;/d' $NGINX_CONF && \
sed -i '/ssl_certificate_key \/etc\/nginx\/ssl\/${DOC_DOMAIN}\/private.key.pem;/d' $NGINX_CONF && \
sed -i '/ssl_protocols TLSv1.3 TLSv1.2;/d' $NGINX_CONF && \
sed -i 's/# listen 80 default_server;/listen 80 default_server;/' $NGINX_CONF; \
fi
# replace ${DOC_DOMAIN} with the DOC_DOMAIN environment variable
RUN sed -i 's/\${DOC_DOMAIN}/'"$DOC_DOMAIN"'/g' $NGINX_CONF
# copy site content
COPY ./app/static /usr/share/nginx/html/$DOC_DOMAIN
# set working directory
WORKDIR /usr/share/nginx/html
# set user variables(do not change)
ARG CONT_USER=nginx
# simple defaults which can be overridden in docker compose
ARG CONT_GRUP=docker_grp
ARG CONT_GID=1000
# Create the group
RUN groupadd -g $CONT_GID -o $CONT_GRUP && usermod -aG $CONT_GRUP $CONT_USER
# set permissions for required folders
RUN chown -R $CONT_USER /usr/share/nginx/html && chmod -R 755 /usr/share/nginx/html && \
chown -R $CONT_USER /var/cache/nginx && \
chown -R $CONT_USER /var/log/nginx && \
chown -R $CONT_USER /etc/nginx/conf.d
RUN mkdir -p /etc/nginx/ssl/ && \
chown -R $CONT_USER /etc/nginx/ssl/ && \
chmod -R 755 /etc/nginx/ssl/
# chown -R $CONT_USER /etc/nginx/ssl/$DOC_DOMAIN/domain.cert.pem && \
# chown -R $CONT_USER /etc/nginx/ssl/$DOC_DOMAIN/private.key.pem && \
# disable root user entirely
RUN chsh -s /usr/sbin/nologin
# activate the user
USER $CONT_USER
EXPOSE 80
# docker build -f Dockerfile.frontend -t ratefront:latest .
# docker run --rm -p 3000:80 ratefront:latest
# docker run -it --rm -p 3000:80 ratefront:latest /bin/bash