Docker Deploy
Pipeline
name: docker-deploydescription: "Build, tag, and push a Docker image then deploy to remote server"steps: - id: get-version run: "git describe --tags --always"
- id: lint run: - "hadolint Dockerfile" - "docker compose config --quiet"
- id: build run: "docker build -t myapp:$PIPE_GET_VERSION ." depends_on: "lint"
- id: push run: | docker tag myapp:$PIPE_GET_VERSION registry.example.com/myapp:$PIPE_GET_VERSION docker push registry.example.com/myapp:$PIPE_GET_VERSION depends_on: "build"
- id: deploy run: "ssh deploy@prod 'docker pull registry.example.com/myapp:$PIPE_GET_VERSION && docker service update --image registry.example.com/myapp:$PIPE_GET_VERSION myapp'" depends_on: "push" retry: 2Concepts demonstrated
- Output passing —
get-versionoutput feeds intobuild,push, anddeployvia$PIPE_GET_VERSION - Parallel commands —
lintruns hadolint and docker compose config concurrently - Dependencies —
build→push→deploychain viadepends_on - Implicit edges —
builddepends onget-versionthrough$PIPE_GET_VERSIONreference - Retry —
deployretries up to 2 times on failure