1 Commits
6 changed files with 39 additions and 73 deletions
+9 -13
View File
@@ -1,9 +1,10 @@
kind: pipeline
type: docker
name: build-test
name: build-and-push
trigger:
event:
- tag
- pull_request
steps:
@@ -12,18 +13,10 @@ steps:
settings:
dockerfile: Dockerfile
context: .
---
kind: pipeline
type: docker
name: build-and-push
when:
event:
- pull_request
trigger:
event:
- push
branch:
- master
steps:
- name: build-and-push
image: plugins/docker
settings:
@@ -31,8 +24,11 @@ steps:
context: .
registry: gitea.jambotron.com
repo: gitea.jambotron.com/liosha84/htop-web
tags: ${DRONE_COMMIT_SHA},main-latest
auto_tag: true
username:
from_secret: REGISTRY_USERNAME
password:
from_secret: REGISTRY_PASSWORD
when:
event:
- tag
-7
View File
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel>
<module name="backend" target="21" />
<module name="backend.main" target="21" />
<module name="backend.test" target="21" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="backend" options="-parameters" />
-3
View File
@@ -6,9 +6,6 @@ This project follows [Semantic Versioning](https://semver.org/). For more detail
## Unreleased
- **Automatic releases on merge** — Drone now builds and pushes Docker images automatically when a Pull Request is merged into `main`. No manual Git tags are needed. Each merge produces two tags: `main-{commit-sha}` for traceability and `main-latest` for the most recent stable build.
- **Git-flow workflow** — development happens in the `develop` branch. When code is ready for release, create a Pull Request from `develop` → `main`. Merging the PR triggers the automatic release.
## v0.3.0
- **CI/CD migrated to Drone** — replaced Gitea Actions with Drone CI/CD (`.drone.yml`). The Docker plugin `auto_tag` feature automatically creates Semantic Versioning tags (`0.3.0`, `0.3`) on Git tag pushes. Configure `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` secrets in the Gitea repository settings.
+1 -1
View File
@@ -23,7 +23,7 @@ FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=builder /app/build/libs/backend-0.0.1-SNAPSHOT.jar app.jar
RUN adduser --disabled-password --gecos "" appuser && \
RUN adduser --disabled-password --no-create-home appuser && \
chown appuser:appuser /app
USER appuser
+3 -5
View File
@@ -35,11 +35,7 @@ def frontendDir = file('../frontend')
def frontendDistDir = file('../frontend/dist/frontend/browser')
def springStaticDir = file('src/main/resources/static')
// Skip frontend build tasks when building inside Docker (frontend already built in Stage 1)
def skipFrontend = project.hasProperty('skipFrontend') || System.getenv('SKIP_FRONTEND') != null
tasks.register('installFrontendDependencies', Exec) {
onlyIf { !skipFrontend }
workingDir frontendDir
inputs.file(file('../frontend/package.json'))
@@ -54,7 +50,6 @@ tasks.register('installFrontendDependencies', Exec) {
}
tasks.register('buildFrontend', Exec) {
onlyIf { !skipFrontend }
dependsOn 'installFrontendDependencies'
workingDir frontendDir
@@ -71,6 +66,9 @@ tasks.register('buildFrontend', Exec) {
}
}
// Skip frontend build tasks when building inside Docker (frontend already built in Stage 1)
def skipFrontend = project.hasProperty('skipFrontend') || System.getenv('SKIP_FRONTEND') != null
tasks.register('copyFrontend', Copy) {
onlyIf { !skipFrontend }
dependsOn 'buildFrontend'
+26 -44
View File
@@ -93,26 +93,11 @@ docker run -d \
## Release process
### Workflow overview
The project uses a **Git-flow** workflow with automatic releases:
1. All development happens in the **`develop`** branch.
2. When code is ready for release, create a **Pull Request** from `develop` → `main`.
3. **Merge the PR** into `main` — this triggers an automatic release.
4. **Drone** builds the Docker image and pushes it to the Gitea Container Registry.
**No manual Git tags are needed** — merging into `main` is the release.
```
develop → PR → merge into main → Drone builds → Docker image pushed
```
### Prerequisites
- Drone CI/CD runner must be configured and running at `drone.jambotron.com`.
- Drone CI/CD runner must be configured and running.
- Gitea Container Registry must be enabled on the server.
- Repository secrets `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` must be set in Drone.
- Repository secrets `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` must be set in the Gitea repository.
### Enabling Container Registry on Gitea server
@@ -151,19 +136,15 @@ sudo systemctl restart gitea
### Configuring Drone CI/CD
The repository uses **Drone** for CI/CD. The configuration file `.drone.yml` is already included in the repository. Drone is hosted at a separate domain: `drone.jambotron.com`.
The repository uses **Drone** for CI/CD. The configuration file `.drone.yml` is already included in the repository.
**1. Log in to Drone.**
**1. Enable Drone for the repository.**
Open `https://drone.jambotron.com` and sign in with your Gitea account.
In Gitea, open the repository and go to **Settings → Drone**. Enable Drone CI/CD for the repository.
**2. Activate the repository in Drone.**
**2. Configure Drone secrets.**
After logging in, find `Liosha84/htop-web` in the repository list and click **Activate**.
**3. Configure Drone secrets.**
In Drone, open the repository and go to **Settings → Secrets**. Add two secrets:
In Gitea, open the repository and go to **Settings → Secrets** (or **Variables and Secrets → Secrets**). Add two secrets:
**First secret:**
- **Name:** `REGISTRY_USERNAME`
@@ -191,48 +172,49 @@ The CI/CD workflow cannot use your account password. You need a Personal Access
### Creating a release
1. **Update `CHANGELOG.md`** with changes for the new version in the `develop` branch.
1. **Update `CHANGELOG.md`** with changes for the new version.
2. **Commit and push** your changes to `develop`:
2. **Commit and push** your changes:
```bash
git checkout develop
git add -A
git commit -m "Feature: new functionality"
git push origin develop
git commit -m "Prepare release v0.2.0"
git push origin master
```
3. **Create a Pull Request** from `develop` → `main`:
3. **Create and push a Git tag** with Semantic Versioning:
Open `https://gitea.jambotron.com/jambotron_gang/htop-web/compare/develop...main` and click **Create Pull Request**.
```bash
git tag -a v0.2.0 -m "Release v0.2.0: new features and fixes"
git push origin v0.2.0
```
4. **Merge the PR** into `main`.
5. **Drone** will automatically:
4. **Drone** will automatically:
- Build the Docker image using the multi-stage Dockerfile
- Tag it with the short commit SHA (e.g., `abc1234`) and `main-latest`
- Push both tags to the Gitea Container Registry
- Auto-tag it using Semantic Versioning: `v0.2.0` produces tags `0.2`, `0.2.0`
- Push all tags to the Gitea Container Registry
### Docker image tags
Each merge into `main` produces two Docker image tags:
Each release produces three Docker image tags:
| Tag | Example | Description |
|-----|---------|-------------|
| Commit SHA | `gitea.jambotron.com/liosha84/htop-web:abc1234` | Exact commit, use for reproducibility |
| Main latest | `gitea.jambotron.com/liosha84/htop-web:main-latest` | Most recent merge into main |
| Full version | `gitea.jambotron.com/liosha84/htop-web:0.2.0` | Exact version, use in production |
| Minor version | `gitea.jambotron.com/liosha84/htop-web:0.2` | Latest patch of 0.2.x |
| Latest | `gitea.jambotron.com/liosha84/htop-web:latest` | Most recent stable release |
### Using a specific version in production
In `docker-compose.yml`, pin to a specific commit SHA:
In `docker-compose.yml`, always pin to a specific version:
```yaml
services:
htop-web:
image: gitea.jambotron.com/liosha84/htop-web:abc1234
image: gitea.jambotron.com/liosha84/htop-web:0.2.0
```
Use `main-latest` for development/testing environments. For production, always use the commit SHA tag so you can roll back to a specific version.
Avoid using `:latest` in production — it makes rollbacks impossible and breaks reproducibility.
## Contribution guidelines