Skip to content

Commit

Permalink
feat: update A2 deliverables and modify CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gerbie-goober committed Aug 7, 2024
1 parent d56e7f0 commit bfd9523
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/A2_Part1.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Pipeline | Build Docker Image
name: CI Pipeline | Build Docker Images

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

jobs:
build_and_push_docker_image:
build_and_push_docker_images:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -24,21 +24,35 @@ jobs:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build the Docker images
run: docker-compose build

- name: Tag and push the Docker images

- name: Build and push Docker image without dependencies (Frontend)
run: |
docker-compose -f docker-compose.yml -f docker-compose.master.yml build frontend
docker tag cscc01-linkup_frontend:master ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_frontend:master
docker push ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_frontend:master
- name: Build and push Docker image without dependencies (Backend)
run: |
docker-compose -f docker-compose.yml -f docker-compose.master.yml build backend
docker tag cscc01-linkup_frontend:master ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_backend:master
docker push ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_backend:master
- name: Build and push Docker image with dependencies (Frontend)
run: |
docker-compose -f docker-compose.yml build frontend
docker tag cscc01-linkup_frontend:latest ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_frontend:latest
docker tag cscc01-linkup_backend:latest ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_backend:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_frontend:latest
- name: Build and push Docker image with dependencies (Backend)
run: |
docker-compose -f docker-compose.yml build backend
docker tag cscc01-linkup_backend:latest ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_backend:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/cscc01-linkup_backend:latest
- name: List Docker images
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/README.md → CICD/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
- Simply, make a PR to the `main` branch or push changes to the `main` branch
- Go to the `Actions` Tab to view the status of the workflow.

## Deliverables
- The automated tests for the backend and frontend can be found in backend/__ tests __ and frontend/__ tests __ respectively
- The Dockerfiles can be found in the backend/ and frontend/ directories
- The docker-compose files can be found in the root directory

## Details of Implementation
- **CI Pipeline**
- Specify that the CI Pipeline is triggered on PR or push to `main`
- Checkout code via `Github Actions`
- Install `docker-compose`
- Log in to Docker Hub
- Run `docker-compose build` to build frontend and backend images
- Run `docker-compose build` to build frontend and backend images with and without dependencies
- **Note**: we have defined a redis container within the docker-compose file in case that we want to implement a test suite that requires redis to run
- Tag frontend and backend images and push them to Docker Hub
- List docker images
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions backend/Dockerfile.master
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:latest

WORKDIR /app

COPY . .

CMD ["npm", "start"]
12 changes: 12 additions & 0 deletions docker-compose.master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.master
image: cscc01-linkup_frontend:master

backend:
build:
context: ./backend
dockerfile: Dockerfile.master
image: cscc01-linkup_backend:master
9 changes: 9 additions & 0 deletions frontend/Dockerfile.master
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:latest

WORKDIR /app

COPY . .

EXPOSE 80

CMD ["npm", "run", "docker"]

0 comments on commit bfd9523

Please sign in to comment.