From 26b933d0a7e9b42e71d941d48a9030bd3858e9c1 Mon Sep 17 00:00:00 2001 From: macieeek Date: Sat, 9 Nov 2024 12:30:06 +0100 Subject: [PATCH] Separate deploy images --- .github/workflows/deploy.yml | 19 ++++++++++++++----- docker/frontend/Dockerfile | 13 +++++++++++++ docker/nginx/Dockerfile | 7 +++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 docker/frontend/Dockerfile create mode 100644 docker/nginx/Dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3576262..55e8eea 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,10 +9,10 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-and-push-image: + build-and-push-images: runs-on: ubuntu-latest strategy: - fail-fast: false + matrix: permissions: contents: read packages: write @@ -27,10 +27,19 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Build and Push + - name: Build and Push Images run: | - docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/portfolio:latest . - docker push ${{ secrets.DOCKERHUB_USERNAME }}/portfolio:latest + cd docker/frontend + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-frontend:latest . + docker push ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-frontend:latest + ls + cd ../../docker/nginx + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-nginx:latest . + docker push ${{ secrets.DOCKERHUB_USERNAME }}/portfolio-nginx:latest + + - name: Build and Push Nginx Image + run: | + deploy: runs-on: ubuntu-latest diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile new file mode 100644 index 0000000..a14d5d4 --- /dev/null +++ b/docker/frontend/Dockerfile @@ -0,0 +1,13 @@ +FROM node:23-alpine AS build + +WORKDIR /var/www/html + +COPY package*.json ./ + +RUN npm install --production + +COPY . . + +RUN npx nuxi build + +CMD ["node", ".output/server/index.mjs"] diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 0000000..14c5cbc --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,7 @@ +FROM nginx:1.27.2-alpine + +COPY ./docker/nginx/prod/nginx.conf /etc/nginx/nginx.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"]