Let’s add a deploy step
Course: CI/CD - chapter 7
- Create dockerfiles for the
appsyou have- Create
docker/Dockerfile.user
- Create
FROM node:20.12.0-alpine3.19
WORKDIR /usr/src/app
COPY package.json package-lock.json turbo.json tsconfig.json ./
COPY apps ./appsCOPY packages ./packages
# Install dependenciesRUN npm install# Can you add a script to the global package.json that does this?RUN cd packages/db && npx prisma generate && cd ../..
# Can you filter the build down to just one app?RUN npm run build
CMD ["npm", "run", "start-user-app"]- Add
start-user-appscript to the rootpackage.json
"start-user-app": "cd ./apps/user-app && npm run start"💡 You dont really need to build every app for every dockerfile. Can you change the build command so that only a single app is built for each dockerfile?

- Create the CD pipeline that
- Clones the repo
- Builds the docker image
- Pushes the docker image
name: Build and Deploy to Docker Hub
on: push: branches: - master
jobs: build-and-push: runs-on: ubuntu-latest steps: - name: Check Out Repo uses: actions/checkout@v2
- name: Log in to Docker Hub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker image uses: docker/build-push-action@v2 with: context: . file: ./Dockerfile push: true tags: 100xdevs/web-app:latest # Replace with your Docker Hub username and repository
- name: Verify Pushed Image run: docker pull 100xdevs/web-app:latest # Replace with your Docker Hub username and repository- Make sure to add the
dockerhubsecrets togithub secretsof the repo (DOCKER_USERNAME, DOCKER_PASSWORD) - You should see a workflow running


Check dockerhub to ensure the image has indeed reached there
Section titled “Check dockerhub to ensure the image has indeed reached there”
💡 You might have to inject more environment variables (like DB URL) in there for the build to work as expected