Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
masnormen committed Nov 30, 2024
1 parent 37692bc commit b766618
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 39 deletions.
46 changes: 7 additions & 39 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
- ziyo-be

env:
REPOSITORY_NAME: "masnormen"
IMAGE_NAME: ${{ github.event.inputs.image-name }}

jobs:
Expand Down Expand Up @@ -42,41 +41,10 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push container image
run: pnpm nx container ${{ env.IMAGE_NAME }}

deploy:
runs-on: ubuntu-latest
needs: build_and_push
environment:
name: ${{ github.event.inputs.image-name }}-production
url: https://ziyo.nourman.com
steps:
- name: Deploy to Droplet
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
envs: IMAGE_NAME,REPOSITORY_NAME
script: |
# Stop and remove old container
docker stop $(echo $IMAGE_NAME) || true
docker rm $(echo $IMAGE_NAME) || true
docker image rm $(docker images '${{ env.REPOSITORY_NAME }}/${{ env.IMAGE_NAME }}' -a -q) || true
# Set the port
if [ $(echo $IMAGE_NAME) = "ziyo-fe" ]; then
PORT=3000
else
PORT=4200
fi
# Run a new container from the new image
docker run -d \
-p $(echo $PORT):$(echo $PORT) \
-e TYPESENSE_API_URL=${{ secrets.TYPESENSE_API_URL }} \
-e TYPESENSE_API_KEY=${{ secrets.TYPESENSE_API_KEY }} \
--restart always \
--name $(echo $IMAGE_NAME) \
$(echo $REPOSITORY_NAME)/$(echo $IMAGE_NAME):latest
- name: Build and Push Docker Image
run: |
IMAGE_TAG=$(git rev-parse --short HEAD)
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG} -f apps/${{ env.IMAGE_NAME }}/Dockerfile .
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3'
services:
watchtower:
image: containrrr/watchtower
command:
- --cleanup=true --interval=30
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ziyo-fe:
image: masnormen/ziyo-fe:latest
ports:
- "3000:3000"
restart: always
ziyo-be:
image: masnormen/ziyo-be:latest
ports:
- "4200:4200"
restart: always
# typesense:
# image: typesense/typesense:27.1
# restart: on-failure
# ports:
# - "8108:8108"
# volumes:
# - ./typesense-data:/data
# command: '--data-dir /data --api-key=xyz --enable-cors'

0 comments on commit b766618

Please sign in to comment.