generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul Admin and Public Dockerfiles (#285)
* Format Caddyfiles * Switch from rhel/ubi8 to alpine in Dockerfiles * Add wildcarded path for node_modules in .dockerignore * Update lockfiles * Node 14 alpine and overhauled Dockerfiles * Reduce files in images, revise env.js and root paths
- Loading branch information
1 parent
3fb484f
commit 58b3524
Showing
10 changed files
with
43,026 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,37 @@ | ||
# RedHat UBI 8 with nodejs 14 | ||
FROM registry.access.redhat.com/ubi8/nodejs-14:1-75.1652296492 as builder | ||
# Global args | ||
ARG build_dir=admin | ||
ARG port=4200 | ||
|
||
# Install packages, build and keep only prod packages | ||
|
||
# Build container | ||
FROM node:14.21.2-alpine3.17 AS build | ||
|
||
# Install dependencies and build static content | ||
ARG build_dir | ||
WORKDIR /app | ||
COPY . ./ | ||
USER root | ||
COPY ./libs ./libs | ||
COPY ./${build_dir} ./${build_dir} | ||
RUN cd libs && \ | ||
npm ci && \ | ||
cd ../admin && \ | ||
cd ../${build_dir} && \ | ||
npm ci && \ | ||
npm run build:admin && \ | ||
rm -rf node_modules | ||
npm run build:${build_dir} && \ | ||
rm -rf node_modules ../libs/node_modules | ||
|
||
# Deployment container | ||
# FROM registry.access.redhat.com/ubi8/ubi-micro | ||
FROM caddy:2 | ||
|
||
# Vars - configured for local development | ||
ENV FOM_ENV=dev | ||
# Deploy container | ||
FROM caddy:2.4.6-alpine | ||
|
||
# Node packages and dependencies | ||
COPY --from=builder /usr/bin/node /usr/bin/ | ||
COPY --from=builder /usr/lib64/libz.so.1 /usr/lib64/ | ||
COPY --from=builder /usr/lib64/libbrotlidec.so.1 /usr/lib64/ | ||
COPY --from=builder /usr/lib64/libbrotlienc.so.1 /usr/lib64/ | ||
COPY --from=builder /usr/lib64/libcrypto.so.1.1 /usr/lib64/ | ||
COPY --from=builder /usr/lib64/libssl.so.1.1 /usr/lib64/ | ||
COPY --from=builder /usr/lib64/libstdc++.so.6 /usr/lib64/ | ||
COPY --from=builder /usr/lib64/libgcc_s.so.1 /usr/lib64/ | ||
COPY --from=builder /usr/lib64/libbrotlicommon.so.1 /usr/lib64/ | ||
|
||
# Copy over app | ||
WORKDIR /app | ||
COPY --from=builder /app/admin/dist ./dist | ||
COPY --from=builder /app/admin ./admin | ||
COPY --from=builder /app/admin/Caddyfile . | ||
# Envar | ||
ENV FOM_ENV=dev | ||
|
||
# Expose port - mostly a convention, for readability | ||
EXPOSE 4200 | ||
# Copy over Caddyfile and static content | ||
ARG build_dir | ||
COPY --from=build /app/${build_dir}/dist/${build_dir} /dist | ||
COPY --from=build /app/${build_dir}/Caddyfile /etc/caddy/Caddyfile | ||
|
||
# Start up command | ||
# Port, health check and user | ||
ARG port | ||
EXPOSE ${port} | ||
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/:${port} | ||
USER 1001 | ||
ENTRYPOINT ["caddy", "run"] |
Oops, something went wrong.