-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile.full
94 lines (62 loc) · 2.46 KB
/
Dockerfile.full
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# syntax=docker/dockerfile:1.0.0-experimental
############# SET UP LIB/LANG DEPENDENCIES #####################
FROM clojure:temurin-8-lein AS linux_setup
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_ACCESS_KEY_ID
ENV NODE_VERSION=16.x
RUN apt-get update;
RUN curl -sL https://deb.nodesource.com/setup_$NODE_VERSION | bash -
RUN apt-get install -qqy openssh-client zip unzip curl git nodejs;
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
# Print out the versions of various infrastructure
RUN lein --version;
RUN npm --version;
RUN node --version;
############# BEGIN BUILD #####################
FROM linux_setup AS builder
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG CDN_HOST
ARG GIT_SHA
ENV TARGET=/app/target
ENV JAR_PATH=$TARGET/storefront.jar
ENV STANDALONE_JAR=/app/target/storefront-*-standalone.jar
WORKDIR /app
ADD project.clj project.clj
ADD . .
RUN lein clean
RUN npm install && (which gulp || npm install -g gulp)
RUN gulp compile-assets --host $CDN_HOST --sha $GIT_SHA
RUN lein deps
RUN lein uberjar
RUN mv $STANDALONE_JAR $JAR_PATH
############# BEGIN ASSET UPLOAD #####################
FROM amazon/aws-cli AS asset_uploader
COPY --from=builder /app/resources/public/cdn /resources/public/cdn
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_ACCESS_KEY_ID
ARG ASSETS_S3_BUCKET
RUN aws configure set default.max_concurrent_requests 5
RUN aws s3 sync /resources/public/cdn \
s3://$ASSETS_S3_BUCKET/cdn \
--debug \
--acl public-read \
--content-encoding gzip \
--cache-control "max-age=315360000" \
--expires $(date --iso-8601 -d "$now + 10 years")
RUN touch /.asset-upload-done
RUN echo "Asset Builder Finished"
RUN ls -l /
############# BEGIN RUNNER #####################
FROM amazoncorretto:8 AS runner
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_ACCESS_KEY_ID
ENV JAR_FILENAME=storefront.jar
ENV TARGET=/app/target
ENV JAR_PATH=$TARGET/storefront.jar
COPY --from=builder $JAR_PATH /$JAR_FILENAME
# This is not necessary, except to tell docker tha the asset_uploader is actually needed and it should not optimize it out of existing.
COPY --from=asset_uploader /.asset-upload-done /.asset-upload-done
RUN curl -o /dd-java-agent.jar -L https://dtdg.co/latest-java-tracer
USER nobody
CMD exec java -javaagent:/dd-java-agent.jar -server -XX:-OmitStackTraceInFastThrow -Xmx1024m -XX:MaxMetaspaceSize=128m -Xss1m -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -jar $JAR_FILENAME