base front production image on official nginx image
This commit is contained in:
parent
3f3af9b957
commit
f1cba60825
@ -9,10 +9,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./
|
context: ./
|
||||||
dockerfile: front/Dockerfile
|
dockerfile: front/Dockerfile
|
||||||
environment:
|
command: /bin/sh -c "/templater.sh && envsubst < /usr/share/nginx/html/env-config.template.js > /usr/share/nginx/html/env-config.js && exec nginx -g 'daemon off;'"
|
||||||
STARTUP_COMMAND_1: 'envsubst < dist/env-config.template.js > dist/env-config.js'
|
|
||||||
STARTUP_COMMAND_2: ''
|
|
||||||
command: apache2-foreground
|
|
||||||
volumes: []
|
volumes: []
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
@ -29,9 +26,6 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./
|
context: ./
|
||||||
dockerfile: pusher/Dockerfile
|
dockerfile: pusher/Dockerfile
|
||||||
environment:
|
|
||||||
STARTUP_COMMAND_1: ''
|
|
||||||
STARTUP_COMMAND_2: ''
|
|
||||||
command: yarn run runprod
|
command: yarn run runprod
|
||||||
volumes: []
|
volumes: []
|
||||||
|
|
||||||
@ -40,8 +34,5 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./
|
context: ./
|
||||||
dockerfile: back/Dockerfile
|
dockerfile: back/Dockerfile
|
||||||
environment:
|
|
||||||
STARTUP_COMMAND_1: ''
|
|
||||||
STARTUP_COMMAND_2: ''
|
|
||||||
command: yarn run runprod
|
command: yarn run runprod
|
||||||
volumes: []
|
volumes: []
|
||||||
|
@ -18,18 +18,11 @@ COPY --from=builder /usr/src/JsonMessages src/Messages/JsonMessages
|
|||||||
RUN yarn run typesafe-i18n && yarn run build-iframe-api && yarn build
|
RUN yarn run typesafe-i18n && yarn run build-iframe-api && yarn build
|
||||||
|
|
||||||
# final production image
|
# final production image
|
||||||
FROM thecodingmachine/nodejs:14-apache
|
FROM nginx:1.21.6-alpine
|
||||||
|
|
||||||
USER root
|
COPY front/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
|
COPY front/templater.sh /
|
||||||
&& apt-get install -y \
|
COPY --from=builder2 /usr/src/dist /usr/share/nginx/html
|
||||||
gettext-base \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
USER docker
|
|
||||||
|
|
||||||
COPY --from=builder2 --chown=docker:docker /usr/src/dist dist
|
EXPOSE 80
|
||||||
COPY front/templater.sh .
|
CMD ["/bin/sh", "-c", "/templater.sh && envsubst < /usr/share/nginx/html/env-config.template.js > /usr/share/nginx/html/env-config.js && exec nginx -g 'daemon off;'"]
|
||||||
|
|
||||||
ENV STARTUP_COMMAND_0="./templater.sh"
|
|
||||||
ENV STARTUP_COMMAND_1="envsubst < dist/env-config.template.js > dist/env-config.js"
|
|
||||||
ENV APACHE_DOCUMENT_ROOT=dist/
|
|
||||||
|
48
front/nginx.conf
Normal file
48
front/nginx.conf
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name localhost;
|
||||||
|
access_log off;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_min_length 1000;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_disable "msie6";
|
||||||
|
gzip_types
|
||||||
|
application/atom+xml
|
||||||
|
application/geo+json
|
||||||
|
application/javascript
|
||||||
|
application/x-javascript
|
||||||
|
application/json
|
||||||
|
application/ld+json
|
||||||
|
application/manifest+json
|
||||||
|
application/rdf+xml
|
||||||
|
application/rss+xml
|
||||||
|
application/xhtml+xml
|
||||||
|
application/xml
|
||||||
|
font/eot
|
||||||
|
font/otf
|
||||||
|
font/ttf
|
||||||
|
image/svg+xml
|
||||||
|
text/css
|
||||||
|
text/javascript
|
||||||
|
text/plain
|
||||||
|
text/xml;
|
||||||
|
|
||||||
|
# serve static assets (that have a cache busting hash) with an efficient cache policy
|
||||||
|
location /assets {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/[@_]/ {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
set -x
|
set -x
|
||||||
set -o nounset errexit
|
set -o nounset errexit
|
||||||
index_file=dist/index.html
|
index_file=/usr/share/nginx/html/index.html
|
||||||
tmp_trackcodefile=/tmp/trackcode
|
tmp_trackcodefile=/tmp/trackcode
|
||||||
|
|
||||||
# To inject tracking code, you have two choices:
|
# To inject tracking code, you have two choices:
|
||||||
@ -10,12 +10,12 @@ tmp_trackcodefile=/tmp/trackcode
|
|||||||
# The ANALYTICS_CODE_PATH is the location of a file inside the container
|
# The ANALYTICS_CODE_PATH is the location of a file inside the container
|
||||||
ANALYTICS_CODE_PATH="${ANALYTICS_CODE_PATH:-dist/ga.html.tmpl}"
|
ANALYTICS_CODE_PATH="${ANALYTICS_CODE_PATH:-dist/ga.html.tmpl}"
|
||||||
|
|
||||||
if [[ "${INSERT_ANALYTICS:-NO}" == "NO" ]]; then
|
if [ "${INSERT_ANALYTICS:-NO}" = "NO" ]; then
|
||||||
echo "" > "${tmp_trackcodefile}"
|
echo "" > "${tmp_trackcodefile}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Automatically insert analytics if GA_TRACKING_ID is set
|
# Automatically insert analytics if GA_TRACKING_ID is set
|
||||||
if [[ "${GA_TRACKING_ID:-}" != "" || "${INSERT_ANALYTICS:-NO}" != "NO" ]]; then
|
if [ "${GA_TRACKING_ID:-}" != "" ] || [ "${INSERT_ANALYTICS:-NO}" != "NO" ]; then
|
||||||
echo "Templating code from ${ANALYTICS_CODE_PATH}"
|
echo "Templating code from ${ANALYTICS_CODE_PATH}"
|
||||||
sed "s#<!-- TRACKING NUMBER -->#${GA_TRACKING_ID:-}#g" "${ANALYTICS_CODE_PATH}" > "$tmp_trackcodefile"
|
sed "s#<!-- TRACKING NUMBER -->#${GA_TRACKING_ID:-}#g" "${ANALYTICS_CODE_PATH}" > "$tmp_trackcodefile"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user