-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
68 lines (62 loc) · 3.01 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
# Build webpack (javascript & css)
FROM node:21.5.0-alpine3.19 AS build-web
WORKDIR /web
COPY web/package.json web/package-lock.json web/webpack.js web/gulpfile.js ./
RUN --mount=type=cache,target=/web/.npm npm ci --no-audit
COPY web/img ./img
COPY web/scss ./scss
COPY web/src ./src
RUN npm run build-css
RUN npm run build-prod
# Build Java
FROM gradle:8.12.1-jdk23-alpine AS build-java
WORKDIR /app
COPY --chown=gradle:gradle java/build.gradle .
COPY --chown=gradle:gradle java/lombok.config .
COPY --chown=gradle:gradle java/src src/
RUN gradle bootJar
WORKDIR build/libs
RUN java -Djarmode=layertools -jar app.jar extract
# Create production image
FROM eclipse-temurin:23-alpine AS prod
LABEL maintainer="oss@ceh.ac.uk"
RUN apk --no-cache add curl
RUN addgroup -g 1001 -S spring && adduser -u 1001 -S spring -G spring
RUN mkdir -p /var/ceh-catalogue/datastore /var/ceh-catalogue/dropbox /var/ceh-catalogue/mapfiles /var/ceh-catalogue/tdb /var/upload/datastore /var/ceh-catalogue/metrics-db /var/ceh-catalogue/ror
WORKDIR /app
COPY --chown=spring:spring schemas /opt/ceh-catalogue/schemas
COPY --chown=spring:spring --from=build-java /app/build/libs/dependencies/ ./
COPY --chown=spring:spring --from=build-java /app/build/libs/spring-boot-loader/ ./
COPY --chown=spring:spring --from=build-java /app/build/libs/snapshot-dependencies/ ./
COPY --chown=spring:spring --from=build-java /app/build/libs/application/ ./
COPY --chown=spring:spring templates /opt/ceh-catalogue/templates
COPY --chown=spring:spring --from=build-web /web/img /opt/ceh-catalogue/static/img
COPY --chown=spring:spring --from=build-web /web/dist /opt/ceh-catalogue/static/scripts
COPY --chown=spring:spring --from=build-web /web/css /opt/ceh-catalogue/static/css
COPY --chown=spring:spring --from=build-web /web/node_modules/leaflet-draw/dist/images /opt/ceh-catalogue/static/css/images
COPY --chown=spring:spring --from=build-web /web/node_modules/@fortawesome/fontawesome-free/webfonts /opt/ceh-catalogue/static/webfonts
RUN chown spring:spring -R /var/ceh-catalogue && chown spring:spring -R /var/upload
VOLUME ["/var/ceh-catalogue/datastore", "/var/ceh-catalogue/dropbox", "/var/ceh-catalogue/mapfiles", "/var/upload/datastore", "/var/ceh-catalogue/metrics-db", "/var/ceh-catalogue/ror"]
EXPOSE 8080 8081
USER spring
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
HEALTHCHECK --start-period=30s CMD curl --no-progress-meter --output - --fail http://localhost:8081/actuator/health || exit 1
# Create Datalabs image
FROM prod AS datalabs
USER root
# Create resources for development only
FROM alpine/git:v2.30.1 AS datastore
COPY fixtures/datastore/REV-1 /datastore
WORKDIR /datastore
RUN git config --global init.defaultBranch main \
&& git init \
&& git config user.email "test@example.com" \
&& git config user.name "test" \
&& git add -A \
&& git commit -m "data loading"
# Development image
FROM prod AS dev
COPY --chown=spring:spring --from=datastore /datastore /var/ceh-catalogue/datastore
USER root
RUN apk --no-cache add git vim
USER spring