forked from grocy/grocy-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile-frontend-tls-selfsigned
72 lines (58 loc) · 2.18 KB
/
Containerfile-frontend-tls-selfsigned
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
69
70
71
72
ARG PLATFORM
FROM --platform=${PLATFORM} docker.io/alpine:3.17.0
LABEL maintainer "Talmai Oliveira <[email protected]>, James Addison <[email protected]>"
ARG GROCY_VERSION
# Install build-time dependencies
RUN apk add --no-cache \
openssl \
git \
gnupg \
wget \
yarn
# Install system dependencies
RUN apk update && \
apk add --no-cache \
nginx
# Generate TLS certificates
RUN openssl req \
-x509 \
-newkey rsa:2048 \
-keyout /etc/ssl/private/grocy-nginx.key \
-out /etc/ssl/private/grocy-nginx.crt \
-days 365 \
-nodes \
-subj /CN=localhost && \
chown nginx /etc/ssl/private/grocy-nginx.key && \
chown nginx /etc/ssl/private/grocy-nginx.crt
# Configure directory permissions
RUN rm -rf /var/www/localhost && \
chown nginx /var/www
COPY static/frontend-tls-selfsigned/nginx.conf /etc/nginx/nginx.conf
COPY static/frontend-tls-selfsigned/common.conf /etc/nginx/common.conf
COPY static/frontend-tls-selfsigned/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY static/frontend-tls-selfsigned/conf.d/ssl.conf /etc/nginx/conf.d/ssl.conf
# Install application dependencies (unprivileged)
USER nginx
WORKDIR /var/www
# Extract application release package
ENV GROCY_RELEASE_KEY_URI="https://berrnd.de/data/Bernd_Bestel.asc"
RUN set -o pipefail && \
export GNUPGHOME=$(mktemp -d) && \
wget ${GROCY_RELEASE_KEY_URI} -O - | gpg --batch --import && \
git clone --branch ${GROCY_VERSION} --config advice.detachedHead=false --depth 1 "https://github.com/grocy/grocy.git" . && \
git verify-commit ${GROCY_VERSION} && \
rm -rf ${GNUPGHOME}
# Install application dependencies
RUN yarn install --frozen-lockfile --modules-folder /var/www/public/node_modules --production && \
yarn cache clean
# Remove build-time dependencies (privileged)
USER root
RUN apk del \
openssl \
git \
gnupg \
wget \
yarn
EXPOSE 8080 8443
USER nginx
CMD ["nginx", "-e", "/proc/self/fd/2", "-g", "daemon off;"]