-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
70 lines (55 loc) · 2.44 KB
/
Dockerfile
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
# Dockerfile to build and serve OperationsGateway
# Build stage
FROM node:22.12.0-alpine3.20@sha256:96cc8323e25c8cc6ddcb8b965e135cfd57846e8003ec0d7bcec16c5fd5f6d39f as builder
WORKDIR /operationsgateway-build
# Enable dependency caching and share the cache between projects
ENV YARN_ENABLE_GLOBAL_CACHE=true
ENV YARN_GLOBAL_FOLDER=/root/.cache/.yarn
COPY package.json tsconfig.json yarn.lock .yarnrc.yml ./
COPY .yarn .yarn
COPY public public
RUN --mount=type=cache,target=/root/.cache/.yarn/cache \
set -eux; \
\
yarn workspaces focus --production;
COPY . .
RUN set -eux; \
\
# Set the React production variable which holds reference to the path of the plugin build \
sed -i "s#VITE_APP_OPERATIONS_GATEWAY_BUILD_DIRECTORY=.*#VITE_APP_OPERATIONS_GATEWAY_BUILD_DIRECTORY=/operationsgateway/#" .env.production; \
\
yarn build;
# Run stage
FROM httpd:2.4.62-alpine3.20@sha256:b64b5734fbc0fbb8fb995d5cc29a2ff2d86ed4c83dfd4f4d82d183f2a66daed4
WORKDIR /usr/local/apache2/htdocs
COPY --from=builder /operationsgateway-build/dist/. ./operationsgateway/
RUN set -eux; \
\
# Enable mod_deflate \
sed -i -e 's/^#LoadModule deflate_module/LoadModule deflate_module/' /usr/local/apache2/conf/httpd.conf; \
# Compress all files except images \
echo 'SetOutputFilter DEFLATE' >> /usr/local/apache2/conf/httpd.conf; \
echo 'SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip' >> /usr/local/apache2/conf/httpd.conf; \
# Disable caching for .js, .json, and .html files \
echo '<FilesMatch ".(js|json|html)$">' >> /usr/local/apache2/conf/httpd.conf; \
echo ' Header set Cache-Control "no-cache"' >> /usr/local/apache2/conf/httpd.conf; \
echo '</FilesMatch>' >> /usr/local/apache2/conf/httpd.conf; \
\
# Privileged ports are permitted to root only by default. \
# setcap to bind to privileged ports (80) as non-root. \
apk --no-cache add libcap; \
setcap 'cap_net_bind_service=+ep' /usr/local/apache2/bin/httpd; \
\
# Change ownership of logs directory \
chown www-data:www-data /usr/local/apache2/logs; \
\
# Change ownership of settings location \
chown www-data:www-data -R /usr/local/apache2/htdocs/operationsgateway;
# Switch to non-root user defined in httpd image
USER www-data
ENV API_URL="/operationsgateway-api"
ENV PLUGIN_HOST="/operationsgateway"
COPY docker/docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["httpd-foreground"]
EXPOSE 80