From 1b7ce26434c8da14f8b27ff1d553c4343d3efe9f Mon Sep 17 00:00:00 2001 From: prasadhonrao Date: Mon, 28 Oct 2024 22:33:50 +0000 Subject: [PATCH] Dockerize webapp and webapi --- src/webapi/dockerize.sh | 2 ++ src/webapp/Dockerfile | 17 +++++++++++++---- src/webapp/dockerize.sh | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/webapi/dockerize.sh create mode 100644 src/webapp/dockerize.sh diff --git a/src/webapi/dockerize.sh b/src/webapi/dockerize.sh new file mode 100644 index 0000000..7e83fe6 --- /dev/null +++ b/src/webapi/dockerize.sh @@ -0,0 +1,2 @@ +docker build -t prasadhonrao/devcamper-webapi . +docker push prasadhonrao/devcamper-webapi \ No newline at end of file diff --git a/src/webapp/Dockerfile b/src/webapp/Dockerfile index fbdedf5..1548e35 100644 --- a/src/webapp/Dockerfile +++ b/src/webapp/Dockerfile @@ -1,5 +1,5 @@ -# Use the official Node.js image as the base image -FROM node:14-alpine +# Stage 1: Build the React application +FROM node:14 AS build # Set the working directory WORKDIR /app @@ -20,11 +20,20 @@ ENV REACT_APP_DEVCAMPER_BASE_API_URI=${REACT_APP_DEVCAMPER_BASE_API_URI} # Build the React application RUN npm run build +# Stage 2: Serve the React application +FROM node:14 AS serve + # Install a simple HTTP server to serve the static files RUN npm install -g serve +# Set the working directory +WORKDIR /app + +# Copy the build artifacts from the previous stage +COPY --from=build /app/build ./build + # Expose the port the app runs on EXPOSE 3000 -# Start the application -CMD ["serve", "-s", "build", "-l", "3000"] \ No newline at end of file +# Serve the React application +CMD ["serve", "-s", "build"] \ No newline at end of file diff --git a/src/webapp/dockerize.sh b/src/webapp/dockerize.sh new file mode 100644 index 0000000..ae4d952 --- /dev/null +++ b/src/webapp/dockerize.sh @@ -0,0 +1,2 @@ +docker build -t prasadhonrao/devcamper-webapp . +docker push prasadhonrao/devcamper-webapp \ No newline at end of file