Skip to content

Commit

Permalink
πŸ”§ fix : BE μ„œλ²„ 3개λ₯Ό 각각 deploy ν•˜λ„λ‘ λ³€κ²½
Browse files Browse the repository at this point in the history
  • Loading branch information
jinddings committed Nov 25, 2024
1 parent 57bc13d commit bdbfbd0
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,34 @@ jobs:
matrix:
app:
[
{ name: 'be', dir: 'BE', port: 3000, container: 'juga-docker-be' },
{ name: 'fe', dir: 'FE', port: 5173, container: 'juga-docker-fe' },
{
name: 'be-1',
dir: 'BE',
port: 3000,
container: 'juga-docker-be-1',
env: 'ENV_BE_1',
},
{
name: 'be-2',
dir: 'BE',
port: 3001,
container: 'juga-docker-be-2',
env: 'ENV_BE_2',
},
{
name: 'be-3',
dir: 'BE',
port: 3002,
container: 'juga-docker-be-3',
env: 'ENV_BE_3',
},
{
name: 'fe',
dir: 'FE',
port: 5173,
container: 'juga-docker-fe',
env: 'ENV_FE',
},
]

steps:
Expand All @@ -35,15 +61,15 @@ jobs:
- name: Create .env file
run: |
touch ./${{ matrix.app.dir }}/.env
echo "${{ secrets.ENV }}" > ./${{matrix.app.dir}}/.env
echo "${{ secrets[matrix.app.env] }}" > ./${{matrix.app.dir}}/.env
- name: Install dependencies
working-directory: ./${{matrix.app.dir}}
continue-on-error: true
run: npm ci

- name: Run tests
if: ${{ matrix.app.name == 'be' }}
if: ${{ contains(matrix.app.name, 'be') }}
working-directory: ./${{matrix.app.dir}}
run: npm test
env:
Expand Down Expand Up @@ -116,15 +142,17 @@ jobs:
script: |
docker system prune -af
echo "${{ secrets.ENV }}" > .env
echo "${{ secrets[matrix.app.env] }}" > .env-${{ matrix.app.name }}
docker network create juga-network || true
docker run -d \
--name redis \
--network juga-network \
-p 6379:6379 \
-v redis_data:/data \
redis:latest redis-server --appendonly yes
if [ "${{ matrix.app.name }}" = "be-1" ]; then
docker run -d \
--name redis \
--network juga-network \
-p 6379:6379 \
-v redis_data:/data \
redis:latest redis-server --appendonly yes
fi
docker pull ${{ env.DOCKER_IMAGE }}-${{ matrix.app.name }}:${{ env.DOCKER_TAG }}
docker stop ${{ matrix.app.container }} || true
Expand All @@ -133,7 +161,7 @@ jobs:
--name ${{ matrix.app.container }} \
--network juga-network \
-p ${{ matrix.app.port }}:${{ matrix.app.port }} \
--env-file .env \
--env-file .env-${{matrix.app.name}} \
${{ env.DOCKER_IMAGE }}-${{ matrix.app.name }}:${{ env.DOCKER_TAG }}
- name: Remove Github Action Ip to Security group
Expand Down

0 comments on commit bdbfbd0

Please sign in to comment.