From c0f09418f459f1d86b30b8670495b66ab3c6311e Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 6 Aug 2024 15:13:19 +0800 Subject: [PATCH 1/2] Adds the Dockerfile that provides a two-stage image that builds the code from checkout and subsequently copies the website folder into a second stage image that runs the website via nginx --- Dockerfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..61abde7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM public.ecr.aws/p9i6h6j0/aws-pdk:latest as build + +#install dependencies +RUN dnf -y install rsync + +# Create a non-root user named 'app' and set up home directory +RUN useradd -m app + +# Create an app directory and change its ownership to the 'app' user +RUN mkdir /app && chown app:app /app + +# Switch to the 'app' user +USER app + +# Set the working directory to the app directory +WORKDIR /app + +#Copy files into the Docker image +COPY --chown=app:app . . +RUN ./scripts/build.sh + +# Stage 2: Serve the application using Nginx +FROM nginx:alpine +# Remove the default nginx website +RUN rm -rf /usr/share/nginx/html/* +# Copy the build output to the nginx html directory +COPY --from=build /app/packages/threat-composer-app/build/website/ /usr/share/nginx/html +# Copy custom nginx configuration if any +#iCOPY nginx.conf /etc/nginx/nginx.conf +# Expose port 80 +EXPOSE 80 +# Start nginx +CMD ["nginx", "-g", "daemon off;"] From d0f975f393e80a80af6d11c3687d6f168298a4b1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 6 Aug 2024 15:16:17 +0800 Subject: [PATCH 2/2] fix typos --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 61abde7..74a7828 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,8 +25,6 @@ FROM nginx:alpine RUN rm -rf /usr/share/nginx/html/* # Copy the build output to the nginx html directory COPY --from=build /app/packages/threat-composer-app/build/website/ /usr/share/nginx/html -# Copy custom nginx configuration if any -#iCOPY nginx.conf /etc/nginx/nginx.conf # Expose port 80 EXPOSE 80 # Start nginx