Add a docker-compose.yml to build frontend app

This commit is contained in:
Murtadha 2024-07-11 23:48:04 -04:00
parent f2559f1fe1
commit 24d325cda3
2 changed files with 58 additions and 6 deletions

View file

@ -32,10 +32,52 @@
# - docker rm frontend || true
# - docker run -d --name frontend -p 5137:5137 frontend:latest
pipeline:
deploy:
image: alpine
commands:
- sh ./deploy.sh
# pipeline:
# deploy:
# image: alpine
# commands:
# - sh ./deploy.sh
branches: master
# branches: master
pipeline:
submodules:
image: alpine/git
commands:
- git submodule update --init --recursive
build:
image: docker:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- cd frontend
- docker build -t mnisyif-frontend .
# Optionally push to a registry
# - docker tag my-frontend-app my-registry/my-frontend-app:latest
# - docker push my-registry/my-frontend-app:latest
deploy:
image: appleboy/drone-ssh
environment:
HOST: "10.0.0.2"
USER: "mnisyif"
SSH_KEY:
from_secret: ssh_key
commands:
- apk add --no-cache openssh
- mkdir -p ~/.ssh
- echo "$SSH_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -H $HOST >> ~/.ssh/known_hosts
- scp frontend/docker-compose.yml $USER@$HOST:/docker-containers/mnisyif
- scp -r frontend/* $USER@$HOST:/docker-containers/mnisyif/frontend/
# If the image is pushed to a registry, pull it on the deployment server
# - ssh $USER@$HOST "cd /path/to/deployment/directory && docker-compose pull && docker-compose up -d"
# If the image is built locally on the CI server, transfer the image file
# - docker save my-frontend-app | bzip2 | ssh $USER@$HOST 'bunzip2 | docker load'
# - ssh $USER@$HOST "cd /path/to/deployment/directory && docker-compose up -d"
secrets:
ssh_key:
external: true

10
docker-compose.yml Normal file
View file

@ -0,0 +1,10 @@
version: '3'
services:
frontend:
image: mnisyif-frontend
build:
context: .
dockerfile: Dockerfile
ports:
- "5173:5173"
restart: always