2023-03-03 15:54:28 +00:00
|
|
|
################## First Stage - Creating base #########################
|
|
|
|
|
|
|
|
# Created a variable to hold our node base image
|
2024-05-21 12:41:10 +00:00
|
|
|
ARG NODE_IMAGE=node:20-bookworm-slim
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
FROM $NODE_IMAGE AS base
|
2023-09-04 11:24:58 +00:00
|
|
|
# Install dumb-init and ClamAV, and perform ClamAV database update
|
|
|
|
RUN apt update \
|
|
|
|
&& apt-get install -y dumb-init clamav clamav-daemon nano \
|
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
|
|
# Creating folders and changing ownerships
|
|
|
|
&& mkdir -p /home/node/app && chown node:node /home/node/app \
|
|
|
|
&& mkdir -p /var/lib/clamav \
|
|
|
|
&& mkdir /usr/local/share/clamav \
|
2023-09-05 16:18:42 +00:00
|
|
|
&& chown -R node:clamav /var/lib/clamav /usr/local/share/clamav /etc/clamav \
|
|
|
|
# permissions
|
|
|
|
&& mkdir /var/run/clamav \
|
|
|
|
&& chown node:clamav /var/run/clamav \
|
|
|
|
&& chmod 750 /var/run/clamav
|
2023-09-04 11:24:58 +00:00
|
|
|
# -----------------------------------------------
|
|
|
|
# --- ClamAV & FeshClam -------------------------
|
|
|
|
# -----------------------------------------------
|
|
|
|
# RUN \
|
|
|
|
# chmod 644 /etc/clamav/freshclam.conf && \
|
|
|
|
# freshclam && \
|
|
|
|
# mkdir /var/run/clamav && \
|
|
|
|
# chown -R clamav:root /var/run/clamav
|
|
|
|
|
|
|
|
# # initial update of av databases
|
|
|
|
# RUN freshclam
|
|
|
|
|
|
|
|
# Configure Clam AV...
|
|
|
|
COPY --chown=node:clamav ./*.conf /etc/clamav/
|
|
|
|
|
2023-09-05 16:18:42 +00:00
|
|
|
# # permissions
|
|
|
|
# RUN mkdir /var/run/clamav && \
|
|
|
|
# chown node:clamav /var/run/clamav && \
|
|
|
|
# chmod 750 /var/run/clamav
|
2023-03-03 15:54:28 +00:00
|
|
|
# Setting the working directory
|
|
|
|
WORKDIR /home/node/app
|
|
|
|
# Changing the current active user to "node"
|
|
|
|
USER node
|
2023-09-04 11:24:58 +00:00
|
|
|
|
|
|
|
# initial update of av databases
|
|
|
|
RUN freshclam
|
|
|
|
|
2023-10-17 13:45:41 +00:00
|
|
|
# VOLUME /var/lib/clamav
|
2023-09-04 11:24:58 +00:00
|
|
|
COPY --chown=node:clamav docker-entrypoint.sh /home/node/app/docker-entrypoint.sh
|
|
|
|
RUN chmod +x /home/node/app/docker-entrypoint.sh
|
|
|
|
ENV TZ="Europe/Vienna"
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
################## Second Stage - Installing dependencies ##########
|
|
|
|
# In this stage, we will start installing dependencies
|
|
|
|
FROM base AS dependencies
|
|
|
|
# We copy all package.* files to the working directory
|
|
|
|
COPY --chown=node:node ./package*.json ./
|
|
|
|
# We run NPM CI to install the exact versions of dependencies
|
|
|
|
RUN npm ci
|
|
|
|
# Lastly, we copy all the files with active user
|
|
|
|
COPY --chown=node:node . .
|
|
|
|
|
|
|
|
|
|
|
|
################## Third Stage - Building Stage #####################
|
|
|
|
# In this stage, we will start building dependencies
|
|
|
|
FROM dependencies AS build
|
2024-09-16 15:59:46 +00:00
|
|
|
ENV NODE_ENV=production
|
2023-09-04 11:24:58 +00:00
|
|
|
# We run "node ace build" to build the app (dist folder) for production
|
2024-07-08 11:52:20 +00:00
|
|
|
RUN node ace build --ignore-ts-errors
|
|
|
|
# RUN node ace build --production
|
2024-05-21 12:41:10 +00:00
|
|
|
# RUN node ace build --ignore-ts-errors
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
################## Final Stage - Production #########################
|
|
|
|
# In this final stage, we will start running the application
|
|
|
|
FROM base AS production
|
|
|
|
# Here, we include all the required environment variables
|
|
|
|
# ENV NODE_ENV=production
|
|
|
|
# ENV PORT=$PORT
|
|
|
|
# ENV HOST=0.0.0.0
|
|
|
|
|
|
|
|
# Copy package.* to the working directory with active user
|
|
|
|
COPY --chown=node:node ./package*.json ./
|
2023-03-17 15:13:37 +00:00
|
|
|
# We run NPM CI to install the exact versions of production dependencies
|
2023-03-03 15:54:28 +00:00
|
|
|
RUN npm ci --omit=dev
|
|
|
|
# Copy files to the working directory from the build folder the user
|
|
|
|
COPY --chown=node:node --from=build /home/node/app/build .
|
|
|
|
# Expose port
|
2023-09-28 20:43:46 +00:00
|
|
|
EXPOSE 3333
|
2023-09-04 11:24:58 +00:00
|
|
|
ENTRYPOINT ["/home/node/app/docker-entrypoint.sh"]
|
2023-03-03 15:54:28 +00:00
|
|
|
# Run the command to start the server using "dumb-init"
|
2024-06-14 10:38:04 +00:00
|
|
|
CMD [ "dumb-init", "node", "bin/server.js" ]
|