Skip to content

Commit

Permalink
feat: frontend container
Browse files Browse the repository at this point in the history
Add a poc to try to build the frontend container locally, and check if
it could be deployed in ephemeral environment.

Signed-off-by: Alejandro Visiedo <[email protected]>
  • Loading branch information
avisiedo committed Nov 14, 2023
1 parent b3a355a commit 2c6d87f
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
65 changes: 65 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
{$CADDY_TLS_MODE}
auto_https disable_redirects
servers {
metrics
}
}

:9000 {
metrics /metrics
}

:8000 {
{$CADDY_TLS_CERT}
log

# Handle main app route
@app_match {
path ${ROUTE_PATH}*
}
handle @app_match {
uri strip_prefix ${ROUTE_PATH}
file_server * {
root /opt/app-root/src/dist
browse
}
}

# Handle beta app route
@beta_match {
path ${BETA_ROUTE_PATH}*
}
handle @beta_match {
uri strip_prefix ${BETA_ROUTE_PATH}
file_server * {
root /opt/app-root/src/dist
browse
}
}

# Handle preview app route
@preview_match {
path ${PREVIEW_ROUTE_PATH}*
}
handle @preview_match {
uri strip_prefix ${PREVIEW_ROUTE_PATH}
file_server * {
root /opt/app-root/src/dist
browse
}
}

handle /beta/ {
redir /beta/apps/chrome/index.html permanent
}

handle /preview/ {
redir /preview/apps/chrome/index.html permanent
}

handle / {
redir /apps/chrome/index.html permanent
}
}

27 changes: 27 additions & 0 deletions build/package/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM registry.redhat.io/rhel9/nodejs-16:1-110 AS builder
USER root
# COPY --chown=1001:1001 package*.json .
COPY package*.json .
# The working dir is at /opt/app-root/src
RUN mkdir -p ".cache/Cypress"
RUN npm install
# COPY --chown=1001:1001 . .
COPY . .
#COPY --from=dependencies --chown=1001:1001 /usr/src/app/node_modules .
RUN npm run build

FROM quay.io/cloudservices/caddy-ubi:11145b1
ENV CADDY_TLS_MODE="http_port 8000"
ENV APP_NAME="idmsvc"
ENV ROUTE_PATH="/apps/${APP_NAME}"
ENV BETA_ROUTE_PATH="/beta/apps/${APP_NAME}"
ENV PREVIEW_ROUTE_PATH="/preview/apps/${APP_NAME}"

COPY Caddyfile /opt/app-root/src/Caddyfile
COPY --from=builder /opt/app-root/src/dist /opt/app-root/src/dist
# COPY package.json /opt/app-root/src
WORKDIR /opt/app-root/src/dist
CMD ["caddy", "run", "--config", "/opt/app-root/src/Caddyfile"]

EXPOSE 8000

0 comments on commit 2c6d87f

Please sign in to comment.