Skip to content

chore(action) fix trigger branch name #5302

chore(action) fix trigger branch name

chore(action) fix trigger branch name #5302

Workflow file for this run

name: Chat Lucy Node API Production
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login docker
run: docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}}
- name: Build docker image
run: |
docker build --build-arg DATABASE_URL="${{secrets.DATABASE_URL}}" \
-t ${{secrets.DOCKER_USERNAME}}/chat_lucy_api:${{ github.sha }} -f apps/api/Dockerfile .
- name: Publish images
run: |
docker push ${{secrets.DOCKER_USERNAME}}/chat_lucy_api:${{ github.sha }}
deploy:
needs: build
runs-on: [self-hosted,main,prod]
steps:
- name: Clean up old images
run: docker system prune -af
- name: Create Docker network
run: docker network create chat-lucy-network || true
- name: Create Docker volumes
run: |
docker volume create chat-lucy-redis-data || true
docker volume create chat-lucy-kafka-data || true
docker volume create chat-lucy-zookeeper-data || true
- name: Deploy Redis with password
run: |
docker rm -f chat-lucy-redis || true
docker run -d \
--name chat-lucy-redis \
--network chat-lucy-network \
--restart unless-stopped \
-v chat-lucy-redis-data:/data \
-p 127.0.0.1:6379:6379 \
redis:alpine redis-server --requirepass ${{secrets.REDIS_PASSWORD}} --appendonly yes
- name: Deploy Kafka and Zookeeper
run: |
docker rm -f chat-lucy-zookeeper || true
docker rm -f chat-lucy-kafka || true
docker run -d \
--name chat-lucy-zookeeper \
--network chat-lucy-network \
--restart unless-stopped \
-v chat-lucy-zookeeper-data:/data \
-p 2181:2181 \
wurstmeister/zookeeper
docker run -d \
--name chat-lucy-kafka \
--network chat-lucy-network \
--restart unless-stopped \
-v chat-lucy-kafka-data:/kafka \
-p 127.0.0.1:9092:9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://chat-lucy-kafka:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=chat-lucy-zookeeper:2181 \
-e KAFKA_CREATE_TOPICS="chats:1:1" \
-e KAFKA_CONNECTIONS_MAX_IDLE_MS=300000 \
-e KAFKA_BROKER_ID=1 \
wurstmeister/kafka
- name: Deploy Kafdrop
run: |
docker rm -f chat-lucy-kafdrop || true
docker run -d \
--name chat-lucy-kafdrop \
--network chat-lucy-network \
--restart unless-stopped \
-p 127.0.0.1:9000:9000 \
-e KAFKA_BROKERCONNECT=chat-lucy-kafka:9092 \
-e JVM_OPTS="-Xms32M -Xmx64M" \
-e SERVER_SERVLET_CONTEXTPATH="/" \
-e BASIC_AUTH_USER="${{secrets.KAFDROP_USER}}" \
-e BASIC_AUTH_PASSWORD="${{secrets.KAFDROP_PASSWORD}}" \
obsidiandynamics/kafdrop
- name: Remove old API container
run: docker rm -f chat-lucy-node-api || true
- name: Run docker container chat-lucy-node-api
run: |
docker run -d -p 3333:3333 \
-e APP_URL="${{secrets.NEXT_PUBLIC_API_URL}}" \
-e API_URL="${{secrets.NEXT_PUBLIC_API_URL}}" \
-e DATABASE_URL="${{secrets.DATABASE_URL}}" \
-e REDIS_URL="redis://:${{secrets.REDIS_PASSWORD}}@chat-lucy-redis:6379" \
-e JWT_SECRET="${{secrets.JWT_SECRET}}" \
-e KAFKA_BROKER="chat-lucy-kafka:9092" \
-e KAFKA_USERNAME="${{secrets.KAFKA_USERNAME}}" \
-e KAFKA_PASSWORD="${{secrets.KAFKA_PASSWORD}}" \
-e KAFKA_TOPIC="chats" \
-e NODE_ENV="production" \
--network chat-lucy-network \
--restart unless-stopped \
--name chat-lucy-node-api-monorepo \
${{secrets.DOCKER_USERNAME}}/chat_lucy_api:${{ github.sha }}