From 0c248b853707aba3affe2ad7d250cc40811876bf Mon Sep 17 00:00:00 2001 From: Ayush Acharjya Date: Tue, 10 Dec 2024 16:23:42 +0000 Subject: [PATCH] add cd --- .github/workflows/deploy.yml | 43 ++++++++++++++++++++++++++++++++++++ docker/Dockerfile.backend | 18 +++++++++++++++ docker/Dockerfile.engine | 17 ++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 docker/Dockerfile.backend create mode 100644 docker/Dockerfile.engine diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..79d60b7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,43 @@ +name: Build, Deploy, and Verify Docker Images + +on: + push: + branches: + - main + +jobs: + build-deploy-verify: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push backend image + run: | + docker build -f docker/Dockerfile.backend -t ayush272002/automarker-backend:latest . + docker push ayush272002/automarker-backend:latest + + - name: Build and push engine image + run: | + docker build -f docker/Dockerfile.mm -t ayush272002/automarker-engine:latest . + docker push ayush272002/automarker-engine:latest + + - name: Verify backend image by pulling + run: | + docker pull ayush272002/automarker-backend:latest + docker images | grep ayush272002/automarker-backend + + - name: Verify engine image by pulling + run: | + docker pull ayush272002/automarker-engine:latest + docker images | grep ayush272002/automarker-engine diff --git a/docker/Dockerfile.backend b/docker/Dockerfile.backend new file mode 100644 index 0000000..1d50be9 --- /dev/null +++ b/docker/Dockerfile.backend @@ -0,0 +1,18 @@ +FROM node:20.12.0-alpine3.19 + +WORKDIR /app + +COPY .gitignore .npmrc prettier.config.js ./ +COPY package.json package-lock.json turbo.json ./ + +COPY apps ./apps +COPY packages ./packages + +RUN npm install + +RUN npm run db:generate +RUN npm run build + +EXPOSE 8000 + +CMD ["npm", "run", "start:backend"] \ No newline at end of file diff --git a/docker/Dockerfile.engine b/docker/Dockerfile.engine new file mode 100644 index 0000000..cd5e0ce --- /dev/null +++ b/docker/Dockerfile.engine @@ -0,0 +1,17 @@ +FROM node:20.12.0-alpine3.19 + +WORKDIR /app + +COPY .gitignore .npmrc prettier.config.js ./ +COPY package.json package-lock.json turbo.json ./ + +COPY apps ./apps +COPY packages ./packages + +RUN npm install + +RUN npm run db:generate +RUN npm run build + + +CMD ["npm", "run", "start:engine"] \ No newline at end of file