creating containers

This commit is contained in:
tawoe 2024-05-07 14:23:25 +02:00
parent ec01a21078
commit 2244629161
4 changed files with 17 additions and 57 deletions

View File

@ -1,25 +1,21 @@
# First stage builds the application
FROM ubi8/nodejs-16 as builder
FROM node:lts-bullseye as builder
# Add application sources
ADD app-src $HOME
ADD ../.. /home/node/app/
WORKDIR /home/node/app
# Install the dependencies
RUN npm install
RUN npm build-server
RUN npm run build-server
# Run script uses standard ways to run the application
CMD npm run -d start
# CMD npm run -d start
FROM node:lts-bullseye
USER 0
COPY --from=builder /app/server-dist /app
WORKDIR /app
RUN chown 1001 /
RUN chown -R 1001 /app
RUN chgrp -R 0 /app && chmod -R g+rwX /app
USER 1001
COPY --from=builder /home/node/app/server-dist /home/node/app
RUN mkdir /home/node/node_modules
COPY --from=builder /home/node/app/node_modules /home/node/node_modules
WORKDIR /home/node/app
CMD ["node", "app.js"]

View File

@ -1,23 +0,0 @@
# First stage builds the application
FROM ubi8/nodejs-16 as builder
# Add application sources
ADD app-src $HOME
# Install the dependencies
RUN npm install
RUN npm build-server
FROM ubi8/nodejs-16-minimal
USER 0
COPY --from=builder $HOME $HOME
RUN chown -R 1001:0 $HOME
USER 1001 Copy the application source and build artifacts from the builder image to this one
# Run script uses standard ways to run the application
CMD npm run -d start

View File

@ -1,7 +1,9 @@
FROM ubi8/nodejs-16 as builder
FROM node:lts-bullseye as builder
USER 0
# Add application sources
ADD .. $HOME
# Add application sources
ADD ../.. /home/node/app/
WORKDIR /home/node/app
# Install the dependencies
RUN npm install
@ -10,8 +12,9 @@ RUN npm run build
FROM registry.access.redhat.com/ubi9/nginx-120
USER 0
RUN dnf update -y
RUN chown -R 1001 /var/log/nginx
ADD Dockerfiles/nginx.conf "${NGINX_DEFAULT_CONF_PATH}"
COPY --from=builder /app/dist /opt/app-root/src
COPY --from=builder /home/node/app/dist /opt/app-root/src
RUN chgrp -R 0 /opt/app-root/src/ && chmod -R g+rwX /opt/app-root/src/
USER 1001
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,23 +1,7 @@
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /app;
root /opt/app-root/src/;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}