-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (62 loc) · 2.92 KB
/
Dockerfile
File metadata and controls
77 lines (62 loc) · 2.92 KB
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
73
74
75
76
77
# Dockerfile to build and serve scigateway
# Build stage
FROM node:24.14.0-alpine@sha256:7fddd9ddeae8196abf4a3ef2de34e11f7b1a722119f91f28ddf1e99dcafdf114 AS builder
WORKDIR /scigateway-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 yarn build
# Run stage
FROM httpd:2.4.66-alpine@sha256:8f26f33a7002658050e9ab2cd6b77502619dfc89d0a6ba2e9e4a202e0ef04596
WORKDIR /usr/local/apache2/htdocs
# Put the output of the build into an apache server
COPY --from=builder /scigateway-build/dist/. .
RUN set -eux; \
\
# Enable mod_rewrite \
sed -i -e 's/^#LoadModule rewrite_module/LoadModule rewrite_module/' /usr/local/apache2/conf/httpd.conf; \
# Enable mod_deflate \
sed -i -e 's/^#LoadModule deflate_module/LoadModule deflate_module/' /usr/local/apache2/conf/httpd.conf; \
echo '<Location / >' >> /usr/local/apache2/conf/httpd.conf; \
echo ' RewriteEngine on' >> /usr/local/apache2/conf/httpd.conf; \
# Don't rewrite files or directories \
echo ' RewriteCond %{REQUEST_FILENAME} -f [OR]' >> /usr/local/apache2/conf/httpd.conf; \
echo ' RewriteCond %{REQUEST_FILENAME} -d' >> /usr/local/apache2/conf/httpd.conf; \
echo ' RewriteRule ^ - [L]' >> /usr/local/apache2/conf/httpd.conf; \
# Rewrite everything else to index.html to allow html5 state links \
echo ' RewriteRule ^ index.html [QSA,L]' >> /usr/local/apache2/conf/httpd.conf; \
echo '</Location>' >> /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 .json and .html files \
echo '<FilesMatch ".(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/;
# Switch to non-root user defined in httpd image
USER www-data
ENV AUTH_PROVIDER="icat"
ENV AUTH_URL="/api"
COPY docker/docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["httpd-foreground"]
EXPOSE 80