Refactor Drone CI and Dockerfile for optimized builds and runtime
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Streamlined `.drone.yml` by removing redundant test-and-jar step, introducing image caching with `cache_from`, and refining conditional triggers. Enhanced `Dockerfile` with multi-stage builds for dependency warming, test execution, and efficient package creation, alongside runtime optimizations for graceful shutdown and resource management.
This commit is contained in:
20
.drone.yml
20
.drone.yml
@ -6,13 +6,6 @@ environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
|
||||
steps:
|
||||
- name: test-and-jar
|
||||
image: gradle:8.10.2-jdk21
|
||||
# No host volumes; keep cache in the container layer only
|
||||
commands:
|
||||
- gradle --version
|
||||
- gradle --no-daemon clean test bootJar
|
||||
|
||||
- name: build-image
|
||||
image: plugins/docker
|
||||
settings:
|
||||
@ -27,11 +20,19 @@ steps:
|
||||
- ${DRONE_BRANCH/\//-}-${DRONE_COMMIT_SHA:0:7}
|
||||
- latest
|
||||
buildkit: true
|
||||
# ⬇️ Pull last image and reuse its layers (huge win)
|
||||
cache_from:
|
||||
- rubble.se:5000/hemhub/api:latest
|
||||
labels:
|
||||
org.opencontainers.image.source: ${DRONE_GIT_HTTP_URL}
|
||||
org.opencontainers.image.revision: ${DRONE_COMMIT_SHA}
|
||||
org.opencontainers.image.created: ${DRONE_BUILD_FINISHED}
|
||||
org.opencontainers.image.version: ${DRONE_TAG:-${DRONE_COMMIT_SHA:0:7}}
|
||||
when:
|
||||
branch:
|
||||
include: [ main, develop ]
|
||||
event:
|
||||
include: [ push, pull_request, tag ]
|
||||
|
||||
- name: publish-tag
|
||||
image: plugins/docker
|
||||
@ -46,11 +47,16 @@ steps:
|
||||
tags:
|
||||
- ${DRONE_TAG}
|
||||
buildkit: true
|
||||
cache_from:
|
||||
- rubble.se:5000/hemhub/api:latest
|
||||
labels:
|
||||
org.opencontainers.image.source: ${DRONE_GIT_HTTP_URL}
|
||||
org.opencontainers.image.revision: ${DRONE_COMMIT_SHA}
|
||||
org.opencontainers.image.created: ${DRONE_BUILD_FINISHED}
|
||||
org.opencontainers.image.version: ${DRONE_TAG}
|
||||
when:
|
||||
event:
|
||||
include: [ tag ]
|
||||
|
||||
trigger:
|
||||
event:
|
||||
|
||||
Reference in New Issue
Block a user