feature/cicd #2
29
.drone.yml
29
.drone.yml
@@ -4,35 +4,36 @@ name: default
|
||||
|
||||
steps:
|
||||
- name: build-and-deploy
|
||||
image: docker:20.10.16-dind
|
||||
privileged: true
|
||||
environment:
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
image: docker:20.10
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
commands:
|
||||
# Start Docker daemon
|
||||
- dockerd-entrypoint.sh &
|
||||
- sleep 10
|
||||
|
||||
# Build the Docker image
|
||||
- docker build -t localhost:5000/counter:latest .
|
||||
|
||||
|
||||
# Push to local registry
|
||||
- docker push localhost:5000/counter:latest
|
||||
|
||||
|
||||
# Stop and remove existing container if it exists
|
||||
- docker stop counter-app || true
|
||||
- docker rm counter-app || true
|
||||
|
||||
|
||||
# Run the new container
|
||||
- docker run -d --name counter-app -p 8080:8080 localhost:5000/counter:latest
|
||||
|
||||
|
||||
# Wait a moment for the container to start
|
||||
- sleep 5
|
||||
|
||||
|
||||
# Test the API
|
||||
- curl -f http://localhost:8080/ || exit 1
|
||||
|
||||
volumes:
|
||||
- name: dockersock
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
- feature/*
|
||||
- feature/*
|
||||
|
||||
Reference in New Issue
Block a user