v0.11.1 Modify pipeline to add volums instead of moving files
This commit is contained in:
parent
2ee1066fc3
commit
e69adeb013
2 changed files with 58 additions and 59 deletions
115
.woodpecker.yml
115
.woodpecker.yml
|
|
@ -1,63 +1,62 @@
|
||||||
# kind: pipeline
|
|
||||||
# type: docker
|
|
||||||
# name: frontend-deployment
|
|
||||||
|
|
||||||
pipeline:
|
pipeline:
|
||||||
build:
|
build:
|
||||||
image: node:22
|
image: node:22
|
||||||
commands:
|
commands:
|
||||||
- npm ci
|
- npm ci
|
||||||
- npm run build
|
- npm run build
|
||||||
|
|
||||||
ssh-copy-to-host:
|
ssh-copy-to-host:
|
||||||
image: appleboy/drone-scp
|
image: appleboy/drone-scp
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
from_secret: ssh_host
|
from_secret: ssh_host
|
||||||
username:
|
username:
|
||||||
from_secret: ssh_username
|
from_secret: ssh_username
|
||||||
key:
|
key:
|
||||||
from_secret: ssh_key
|
from_secret: ssh_key
|
||||||
port: 2332
|
port: 2332
|
||||||
target: /home/mnisyif/docker-containers/mnisyif/frontend
|
target: /home/mnisyif/docker-containers/mnisyif/frontend
|
||||||
source:
|
source:
|
||||||
- dist/
|
- dist/
|
||||||
- Dockerfile
|
- Dockerfile
|
||||||
- nginx.conf
|
- nginx.conf
|
||||||
- version.txt
|
- version.txt
|
||||||
|
|
||||||
webserver-docker-deploy:
|
webserver-docker-deploy:
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
from_secret: ssh_host
|
from_secret: ssh_host
|
||||||
username:
|
username:
|
||||||
from_secret: ssh_username
|
from_secret: ssh_username
|
||||||
key:
|
key:
|
||||||
from_secret: ssh_key
|
from_secret: ssh_key
|
||||||
port: 2332
|
port: 2332
|
||||||
script:
|
script:
|
||||||
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
||||||
- VERSION=$(cat version.txt)
|
- VERSION=$(cat version.txt)
|
||||||
# Build the new Docker image with the current version tag
|
# Build the Docker image (no dist or nginx.conf needed in image)
|
||||||
- docker build -t frontend:$VERSION .
|
- docker build -t frontend:$VERSION .
|
||||||
# Stop and remove the existing container if it exists
|
# Stop and remove the existing container if it exists
|
||||||
- docker stop frontend || true
|
- docker stop frontend || true
|
||||||
- docker rm frontend || true
|
- docker rm frontend || true
|
||||||
# Run the new container with the current version
|
# Run the new container with bind mounts for dist and nginx.conf
|
||||||
- docker run -d --name frontend -p 5173:80 frontend:$VERSION
|
- docker run -d --name frontend -p 5173:80 \
|
||||||
# Remove dangling images
|
-v /home/mnisyif/docker-containers/mnisyif/frontend/dist:/usr/share/nginx/html \
|
||||||
- docker image prune -f
|
-v /home/mnisyif/docker-containers/mnisyif/frontend/nginx.conf:/etc/nginx/nginx.conf \
|
||||||
# Clean up unused containers, images, and volumes
|
frontend:$VERSION
|
||||||
- docker system prune -f --volumes
|
# Remove dangling images
|
||||||
# Remove older versions of the Docker image
|
- docker image prune -f
|
||||||
- >
|
# Clean up unused containers, images, and volumes
|
||||||
for img in $(docker images frontend --format "{{.Tag}}" | grep -v $VERSION); do
|
- docker system prune -f --volumes
|
||||||
docker rmi frontend:$img;
|
# Remove older versions of the Docker image
|
||||||
done
|
- >
|
||||||
|
for img in $(docker images frontend --format "{{.Tag}}" | grep -v $VERSION); do
|
||||||
|
docker rmi frontend:$img;
|
||||||
|
done
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
|
|
@ -1 +1 @@
|
||||||
0.11.0
|
0.11.1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue