-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile and docker build step
- Loading branch information
1 parent
680d48b
commit 3954614
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |