-
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.
Dockerize slackbot and setup prod server
- Loading branch information
1 parent
84ebeff
commit bca026b
Showing
4 changed files
with
68 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build and Deploy to Cloud VM | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
setup-build-publish-deploy: | ||
name: Setup, Build, Publish, and Deploy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Auth Docker | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Get SHA | ||
id: vars | ||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | ||
|
||
# Build the Docker image | ||
- name: Build | ||
run: |- | ||
docker build --tag "cuappdev/big-red-bot:${{ steps.vars.outputs.sha_short }}" . | ||
# Push the Docker image to Google Container Registry | ||
- name: Publish | ||
run: |- | ||
docker push "cuappdev/big-red-bot:${{ steps.vars.outputs.sha_short }}" | ||
- name: SSH & Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USER }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
export SLACK_BOT_IMG_TAG="${{ steps.vars.outputs.sha_short }}" | ||
docker stop big-red-bot-backend-web-1 | ||
docker rm big-red-bot-backend-web-1 | ||
yes | sudo docker container prune | ||
yes | sudo docker system prune | ||
docker compose -p big-red-bot-backend up -d |
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,13 @@ | ||
FROM node:16 | ||
|
||
RUN mkdir /usr/app | ||
WORKDIR /usr/app | ||
|
||
# Copy these files first to optimize cache | ||
COPY package.json . | ||
COPY yarn.lock . | ||
|
||
RUN yarn install | ||
COPY . . | ||
EXPOSE 3000 8000 | ||
CMD ["yarn", "start"] |
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,7 @@ | ||
services: | ||
web: | ||
image: cuappdev/big-red-bot:${SLACK_BOT_IMG_TAG} | ||
env_file: .env | ||
ports: | ||
- "3000:3000" | ||
- "8000:8000" |
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