Skip to content

Commit

Permalink
Add Dockerfile and docker build step
Browse files Browse the repository at this point in the history
  • Loading branch information
lyncasterc committed Mar 30, 2024
1 parent 680d48b commit 3954614
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
30 changes: 29 additions & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,38 @@ jobs:
run: cd ../frontend && npm install
- name: build ui
run: npm run build:ui

build-and-push-docker:
runs-on: ubuntu-20.04
needs: [build]
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: user/instaclone:latest

deploy:
if: ${{ github.ref == 'refs/head/main' }}
runs-on: ubuntu-20.04
needs: [build]
needs: [build-and-push-docker]
steps:
- uses: actions/checkout@v2
- uses: akhileshns/[email protected]
Expand Down
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# BUILD STAGE

FROM node:16 as build-stage
WORKDIR /app

# copying the all the frontend and backend code
COPY frontend ./frontend
COPY backend ./backend

# installing the frontend and backend dependencies
RUN cd frontend && npm install
RUN cd backend && npm install

# building the frontend UI from the backend
RUN cd backend && npm run build:ui

# compiling TypeScript code
RUN cd backend && npm run tsc

# RUN STAGE

FROM node:16 as run-stage
WORKDIR /app

# copying the built frontend and backend code
COPY --from=build-stage /app/backend/build /app

# copying the backend package.json
COPY --from=build-stage /app/backend/package.json /app

# Installing the backend dependencies
RUN npm install --omit=dev

EXPOSE 3001

CMD ["node", "index.js"]

0 comments on commit 3954614

Please sign in to comment.