From 216c19f453959fa44c32a889fcb2bc4bf5c42eca Mon Sep 17 00:00:00 2001 From: Toni Tienda Date: Thu, 21 Mar 2024 09:30:27 +0100 Subject: [PATCH] feat: adds dockerfile to build the react based webapp --- .github/workflows/build-run-test.yaml | 4 +++- webapp-react/Dockerfile | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 webapp-react/Dockerfile diff --git a/.github/workflows/build-run-test.yaml b/.github/workflows/build-run-test.yaml index 1eeed81..f8e73f2 100644 --- a/.github/workflows/build-run-test.yaml +++ b/.github/workflows/build-run-test.yaml @@ -10,5 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Build Docker image + - name: Build Golang Rest Backend Docker image run: docker build -t backend-golang-rest backend-golang-rest + - name: Build React WebApp Docker image + run: docker build -t webapp-react webapp-react diff --git a/webapp-react/Dockerfile b/webapp-react/Dockerfile new file mode 100644 index 0000000..d29160a --- /dev/null +++ b/webapp-react/Dockerfile @@ -0,0 +1,24 @@ +# Stage 1: Build the application +FROM node:18-alpine AS build + +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm install --frozen-lockfile + +COPY . . +RUN npm run build + +# Stage 2: Create the production image +FROM node:18-alpine + +WORKDIR /app + +COPY --from=build /app/package.json /app/package-lock.json ./ +RUN npm install --production --frozen-lockfile + +COPY --from=build /app/.next ./.next + +EXPOSE 3000 + +CMD ["npm", "start"] \ No newline at end of file