@@ -26,46 +26,47 @@ RUN chmod +x heplify
2626# #
2727FROM alpine:3.19 AS runner
2828
29- ARG PKCS12_PASSWORD=changeme
30- ARG POSTGRES_USER=postgres
31- ARG POSTGRES_PASSWORD=postgres
29+ ARG PKCS12_PASSWORD=" changeme"
30+ ARG POSTGRES_USER=" postgres"
31+ ARG POSTGRES_PASSWORD=" postgres"
3232ARG CA_CERT_SUBJECT="/CN=Self Signed CA"
3333ARG SERVER_CERT_SUBJECT="/CN=localhost"
34- ARG PRISMA_VERSION=5.9.1
35- ARG DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/routr
34+ ARG PRISMA_VERSION=" 5.9.1"
35+ ARG DATABASE_URL=" postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/routr"
3636
3737ENV PKCS12_PASSWORD=$PKCS12_PASSWORD \
38- PATH_TO_CERTS=/etc/routr/certs \
39- USER=fonoster \
38+ PATH_TO_CERTS=" /etc/routr/certs" \
39+ USER=" fonoster" \
4040 GID=5000 \
4141 UID=5000 \
42- JAVA_HOME=/service/jre \
43- EDGEPORT_RUNNER=/service/edgeport.sh \
42+ JAVA_HOME=" /service/jre" \
43+ EDGEPORT_RUNNER=" /service/edgeport.sh" \
4444 TLS_ON=false \
4545 VERIFY_CLIENT_CERT=false \
4646 CA_CERT_SUBJECT=$CA_CERT_SUBJECT \
4747 SERVER_CERT_SUBJECT=$SERVER_CERT_SUBJECT \
4848 DATABASE_URL=$DATABASE_URL \
4949 IGNORE_LOOPBACK_FROM_LOCALNETS=true \
5050 PRISMA_VERSION=$PRISMA_VERSION \
51- START_INTERNAL_DB=true
51+ START_INTERNAL_DB=true \
52+ LOG4J2="/etc/routr/log4j2.yaml"
5253
5354WORKDIR /service
5455
5556COPY mods/edgeport/edgeport.sh .
5657COPY mods/edgeport/libs libs
58+ COPY mods/pgdata/schema.prisma .
59+ COPY mods/pgdata/migrations migrations
60+ COPY mods/edgeport/etc/log4j2.yaml /etc/routr/log4j2.yaml
5761COPY etc/edgeport.yaml config/edgeport.yaml
58- COPY config/log4j2.yaml mods/edgeport/etc/log4j2.yaml
5962COPY .scripts/convert-to-p12.sh .
6063COPY .scripts/generate-certs.sh .
64+ COPY .scripts/init-postgres.sh .
6165COPY --from=builder /work/dist dist
6266COPY --from=builder /work/node_modules node_modules
6367COPY --from=builder /work/package.json .
6468COPY --from=builder /work/jre jre
6569COPY --from=builder /work/heplify /usr/local/bin/
66- COPY .scripts/init-postgres.sh .
67- COPY mods/pgdata/schema.prisma .
68- COPY mods/pgdata/migrations migrations
6970
7071RUN apk add --no-cache libcap nodejs npm openssl postgresql sed sngrep su-exec tini \
7172 && npm install -g prisma@${PRISMA_VERSION} \
@@ -74,25 +75,26 @@ RUN apk add --no-cache libcap nodejs npm openssl postgresql sed sngrep su-exec t
7475 && adduser --disabled-password --gecos "" --ingroup ${USER} --home ${HOME} --uid ${UID} ${USER} \
7576 && chown -R ${USER}:${USER} /service /etc/routr \
7677 && chown -R postgres:postgres /var/lib/postgresql/data /run/postgresql /root/.npm \
77- && chmod +x edgeport.sh convert-to-p12.sh init-postgres.sh \
78+ && chmod +x edgeport.sh convert-to-p12.sh init-postgres.sh generate-certs.sh \
7879 && chmod 2777 /run/postgresql \
7980 && setcap 'CAP_NET_RAW+eip' /usr/bin/sngrep \
8081 && rm -rf /var/cache/apk/* /tmp/* \
81- && rm -rf /root/.npm /root/.config /root/.cache /root/.local \
82+ && rm -rf /root/.npm /root/.config /root/.cache /root/.local package.json \
8283 && apk del libcap
8384
8485# Re-mapping the signal from 143 to 0
8586ENTRYPOINT ["tini" , "-v" , "-e" , "143" , "--" ]
8687
87- CMD ["sh" , "-c" , "if [ \" $START_INTERNAL_DB\" = \" true\" ]; then \
88+ CMD ["/bin/ sh" , "-c" , "if [ \" $START_INTERNAL_DB\" = \" true\" ]; then \
8889 su-exec postgres /service/init-postgres.sh; \
8990 su-exec postgres pg_ctl start -D /var/lib/postgresql/data --options='-h 0.0.0.0'; \
90- fi && \
91- DATABASE_URL=${DATABASE_URL} npx prisma@${PRISMA_VERSION} migrate deploy --schema=/service/schema.prisma && \
92- su-exec $USER ./convert-to-p12.sh $PATH_TO_CERTS $PKCS12_PASSWORD && \
91+ fi; \
9392 if [ -n \" $HEPLIFY_OPTIONS\" ]; then \
9493 heplify $HEPLIFY_OPTIONS & \
95- fi && \
96- sed -i 's|keyStorePassword: .*|keyStorePassword: ${PKCS12_PASSWORD}|g' config/edgeport.yaml && \
97- sed -i 's|trustStorePassword: .*|trustStorePassword: ${PKCS12_PASSWORD}|g' config/edgeport.yaml && \
98- su-exec $USER node ./dist/runner" ]
94+ fi; \
95+ npx prisma migrate deploy --schema=/service/schema.prisma; \
96+ sed -i \" s|keyStorePassword:.*|keyStorePassword: $PKCS12_PASSWORD|g\" config/edgeport.yaml; \
97+ sed -i \" s|trustStorePassword:.*|trustStorePassword: $PKCS12_PASSWORD|g\" config/edgeport.yaml; \
98+ su-exec $USER ./convert-to-p12.sh $PATH_TO_CERTS $PKCS12_PASSWORD; \
99+ su-exec $USER node ./dist/runner" \
100+ ]
0 commit comments