From 583a19a8a1c48544121d891fb64a01e638d98efb Mon Sep 17 00:00:00 2001 From: James Date: Tue, 13 Feb 2024 17:24:56 -0500 Subject: [PATCH] Update to use httpd --- .gitignore | 3 +++ Dockerfile | 26 +++++++++++++++++++++++--- Dockerfile.node | 16 ++++++++++++++++ supervisord.conf | 10 ++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 Dockerfile.node create mode 100644 supervisord.conf diff --git a/.gitignore b/.gitignore index 7ef691ba..2b88a84d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store node_modules /build +/cert /.svelte-kit /playwright-report /package @@ -11,3 +12,5 @@ node_modules vite.config.js.timestamp-* vite.config.ts.timestamp-* .vscode +/certs +/httpd-docker-logs \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7d1a11fd..a5088ddb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# Step 1: Build the app with node FROM node:20.9.0-alpine3.18 AS builder WORKDIR /app COPY package*.json . @@ -6,11 +7,30 @@ COPY . . RUN npm run build RUN npm ci --omit dev -FROM node:20.9.0-alpine3.18 +# Step 2: Serve the app with httpd +FROM httpd:2.4.54-alpine + +RUN apk add --update openssl sed nodejs supervisor +#TODO: volume mount the certs +RUN mkdir -p ${HTTPD_PREFIX}/cert +COPY cert ${HTTPD_PREFIX}/cert +COPY httpd-vhosts.conf ${HTTPD_PREFIX}/conf/extra/httpd-vhosts.conf + +RUN sed -i '/^#Include conf.extra.httpd-vhosts.conf/s/^#//' ${HTTPD_PREFIX}/conf/httpd.conf + +RUN sed -i '/^#LoadModule proxy_module/s/^#//' ${HTTPD_PREFIX}/conf/httpd.conf +RUN sed -i '/^#LoadModule proxy_http_module/s/^#//' ${HTTPD_PREFIX}/conf/httpd.conf +RUN sed -i '/^#LoadModule proxy_connect_module/s/^#//' ${HTTPD_PREFIX}/conf/httpd.conf + +RUN sed -i '/^#LoadModule ssl_module modules\/mod_ssl.so/s/^#//' ${HTTPD_PREFIX}/conf/httpd.conf +RUN sed -i '/^#LoadModule rewrite_module modules\/mod_rewrite.so/s/^#//' ${HTTPD_PREFIX}/conf/httpd.conf +RUN sed -i '/^#LoadModule socache_shmcb_module modules\/mod_socache_shmcb.so/s/^#//' ${HTTPD_PREFIX}/conf/httpd.conf +RUN mkdir -p /usr/local/apache2/logs/ssl_mutex + WORKDIR /app COPY --from=builder /app/build build/ COPY --from=builder /app/node_modules node_modules/ COPY package.json . -EXPOSE 3000 ENV NODE_ENV=production -CMD [ "node", "build" ] +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/Dockerfile.node b/Dockerfile.node new file mode 100644 index 00000000..7d1a11fd --- /dev/null +++ b/Dockerfile.node @@ -0,0 +1,16 @@ +FROM node:20.9.0-alpine3.18 AS builder +WORKDIR /app +COPY package*.json . +RUN npm ci +COPY . . +RUN npm run build +RUN npm ci --omit dev + +FROM node:20.9.0-alpine3.18 +WORKDIR /app +COPY --from=builder /app/build build/ +COPY --from=builder /app/node_modules node_modules/ +COPY package.json . +EXPOSE 3000 +ENV NODE_ENV=production +CMD [ "node", "build" ] diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 00000000..d8d25f49 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,10 @@ +[supervisord] +nodaemon=true + +[program:httpd] +command=httpd-foreground + +[program:node] +command=node build +directory=/app +