Skip to content

Commit

Permalink
feat: Multi-stage build Dockerfile for building and serving threat co…
Browse files Browse the repository at this point in the history
…mposer. Close #97 (#128)

* 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
  • Loading branch information
UrfTheManatee authored Aug 8, 2024
1 parent 42ede80 commit ebd037b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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
# Expose port 80
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit ebd037b

Please sign in to comment.