Compare commits
19
Commits
v0.2.2
..
ffc1026ce1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffc1026ce1 | ||
|
|
0680557886 | ||
|
|
ea453bd409 | ||
|
|
3c85936c73 | ||
|
|
6666fca194 | ||
|
|
9d03b0977d | ||
|
|
3a0c22abf0 | ||
|
|
ed48cacfbc | ||
|
|
3f9ecc1113 | ||
|
|
eb73c55ac2 | ||
|
|
8369b2a6ba | ||
|
|
d4a6726930 | ||
|
|
0d6e0fa565 | ||
|
|
3e78dcff0f | ||
|
|
291167e683 | ||
|
|
42f606610a | ||
|
|
dc8c6b0dc6 | ||
|
|
7f2ea4f3b4 | ||
|
|
923b1e7c57 |
+38
@@ -0,0 +1,38 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build-test
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build-test
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
context: .
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build-and-push
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build-and-push
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
context: .
|
||||||
|
registry: gitea.jambotron.com
|
||||||
|
repo: gitea.jambotron.com/liosha84/htop-web
|
||||||
|
tags: ${DRONE_COMMIT_SHA},main-latest
|
||||||
|
username:
|
||||||
|
from_secret: REGISTRY_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: REGISTRY_PASSWORD
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
name: Docker Build and Push
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: gitea.jambotron.com
|
|
||||||
IMAGE_NAME: liosha84/htop-web
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Extract version from tag
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
# Remove 'refs/tags/v' prefix from tag (e.g., refs/tags/v0.1.0 → 0.1.0)
|
|
||||||
VERSION=$(echo "${{ gitea.ref }}" | sed 's|refs/tags/v||')
|
|
||||||
echo "Extracted version: ${VERSION}"
|
|
||||||
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
|
||||||
|
|
||||||
# Extract major.minor for minor tag (e.g., 0.1.0 → 0.1)
|
|
||||||
MINOR=$(echo "${VERSION}" | sed 's/\.[0-9]*$//')
|
|
||||||
echo "Extracted minor: ${MINOR}"
|
|
||||||
echo "minor=${MINOR}" >> "${GITHUB_OUTPUT}"
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.minor }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
Generated
+7
@@ -1,5 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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">
|
<component name="JavacSettings">
|
||||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
<module name="backend" options="-parameters" />
|
<module name="backend" options="-parameters" />
|
||||||
|
|||||||
+8
-1
@@ -6,9 +6,16 @@ This project follows [Semantic Versioning](https://semver.org/). For more detail
|
|||||||
|
|
||||||
## Unreleased
|
## 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.
|
||||||
|
|
||||||
## v0.2.0
|
## v0.2.0
|
||||||
|
|
||||||
- **CI/CD with Gitea Actions** — automated Docker image build and push on Git tags. Each release produces three tags: full version (`0.2.0`), minor version (`0.2`), and `latest`. Configure `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` secrets in Gitea repository settings.
|
- **CI/CD with Drone** — automated Docker image build and push on Git tags using Drone CI/CD. Each release produces three tags: full version (`0.2.0`), minor version (`0.2`), and `latest`. Configure `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` secrets in Gitea repository settings.
|
||||||
- **Docker build optimization** — added `.dockerignore` to exclude unnecessary files from the build context, reducing build time and image size.
|
- **Docker build optimization** — added `.dockerignore` to exclude unnecessary files from the build context, reducing build time and image size.
|
||||||
- **Release documentation** — added detailed release process guide in `docs/DEVELOPMENT.md` with Semantic Versioning workflow.
|
- **Release documentation** — added detailed release process guide in `docs/DEVELOPMENT.md` with Semantic Versioning workflow.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ FROM eclipse-temurin:21-jre
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /app/build/libs/backend-0.0.1-SNAPSHOT.jar app.jar
|
COPY --from=builder /app/build/libs/backend-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
|
||||||
RUN adduser --disabled-password --no-create-home appuser && \
|
RUN adduser --disabled-password --gecos "" appuser && \
|
||||||
chown appuser:appuser /app
|
chown appuser:appuser /app
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,11 @@ def frontendDir = file('../frontend')
|
|||||||
def frontendDistDir = file('../frontend/dist/frontend/browser')
|
def frontendDistDir = file('../frontend/dist/frontend/browser')
|
||||||
def springStaticDir = file('src/main/resources/static')
|
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) {
|
tasks.register('installFrontendDependencies', Exec) {
|
||||||
|
onlyIf { !skipFrontend }
|
||||||
workingDir frontendDir
|
workingDir frontendDir
|
||||||
|
|
||||||
inputs.file(file('../frontend/package.json'))
|
inputs.file(file('../frontend/package.json'))
|
||||||
@@ -50,6 +54,7 @@ tasks.register('installFrontendDependencies', Exec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.register('buildFrontend', Exec) {
|
tasks.register('buildFrontend', Exec) {
|
||||||
|
onlyIf { !skipFrontend }
|
||||||
dependsOn 'installFrontendDependencies'
|
dependsOn 'installFrontendDependencies'
|
||||||
workingDir frontendDir
|
workingDir frontendDir
|
||||||
|
|
||||||
@@ -66,9 +71,6 @@ 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) {
|
tasks.register('copyFrontend', Copy) {
|
||||||
onlyIf { !skipFrontend }
|
onlyIf { !skipFrontend }
|
||||||
dependsOn 'buildFrontend'
|
dependsOn 'buildFrontend'
|
||||||
|
|||||||
+59
-36
@@ -93,11 +93,26 @@ docker run -d \
|
|||||||
|
|
||||||
## Release process
|
## 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
|
### Prerequisites
|
||||||
|
|
||||||
- Gitea Actions runner must be configured and running.
|
- Drone CI/CD runner must be configured and running at `drone.jambotron.com`.
|
||||||
- Gitea Container Registry must be enabled on the server.
|
- Gitea Container Registry must be enabled on the server.
|
||||||
- Repository secrets `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` must be set in the Gitea repository.
|
- Repository secrets `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` must be set in Drone.
|
||||||
|
|
||||||
### Enabling Container Registry on Gitea server
|
### Enabling Container Registry on Gitea server
|
||||||
|
|
||||||
@@ -134,6 +149,30 @@ sudo systemctl restart gitea
|
|||||||
|
|
||||||
**4. Verify** that the registry is working by visiting `https://gitea.jambotron.com/user/packages` — you should see a "Packages" tab.
|
**4. Verify** that the registry is working by visiting `https://gitea.jambotron.com/user/packages` — you should see a "Packages" tab.
|
||||||
|
|
||||||
|
### 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`.
|
||||||
|
|
||||||
|
**1. Log in to Drone.**
|
||||||
|
|
||||||
|
Open `https://drone.jambotron.com` and sign in with your Gitea account.
|
||||||
|
|
||||||
|
**2. Activate the repository in Drone.**
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
**First secret:**
|
||||||
|
- **Name:** `REGISTRY_USERNAME`
|
||||||
|
- **Value:** `Liosha84` (your Gitea username)
|
||||||
|
|
||||||
|
**Second secret:**
|
||||||
|
- **Name:** `REGISTRY_PASSWORD`
|
||||||
|
- **Value:** paste the Access Token with `write:package` and `read:package` scopes.
|
||||||
|
|
||||||
### Creating an Access Token for CI/CD
|
### Creating an Access Token for CI/CD
|
||||||
|
|
||||||
The CI/CD workflow cannot use your account password. You need a Personal Access Token with package permissions:
|
The CI/CD workflow cannot use your account password. You need a Personal Access Token with package permissions:
|
||||||
@@ -150,66 +189,50 @@ The CI/CD workflow cannot use your account password. You need a Personal Access
|
|||||||
7. Click **Generate**.
|
7. Click **Generate**.
|
||||||
8. **Copy the token** — it will be shown only once! Save it securely.
|
8. **Copy the token** — it will be shown only once! Save it securely.
|
||||||
|
|
||||||
### Configuring repository secrets
|
|
||||||
|
|
||||||
1. Open the repository: `https://gitea.jambotron.com/Liosha84/htop-web`.
|
|
||||||
2. Go to **Settings** (tab at the top).
|
|
||||||
3. In the left menu: **Secrets** (or **Variables and Secrets → Secrets**).
|
|
||||||
4. Click **Add secret**.
|
|
||||||
|
|
||||||
**First secret:**
|
|
||||||
- **Name:** `REGISTRY_USERNAME`
|
|
||||||
- **Value:** `Liosha84` (your Gitea username)
|
|
||||||
|
|
||||||
**Second secret:**
|
|
||||||
- **Name:** `REGISTRY_PASSWORD`
|
|
||||||
- **Value:** paste the Access Token you created in the previous step.
|
|
||||||
|
|
||||||
### Creating a release
|
### Creating a release
|
||||||
|
|
||||||
1. **Update `CHANGELOG.md`** with changes for the new version.
|
1. **Update `CHANGELOG.md`** with changes for the new version in the `develop` branch.
|
||||||
|
|
||||||
2. **Commit and push** your changes:
|
2. **Commit and push** your changes to `develop`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
git checkout develop
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "Prepare release v0.2.0"
|
git commit -m "Feature: new functionality"
|
||||||
git push origin master
|
git push origin develop
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Create and push a Git tag** with Semantic Versioning:
|
3. **Create a Pull Request** from `develop` → `main`:
|
||||||
|
|
||||||
```bash
|
Open `https://gitea.jambotron.com/jambotron_gang/htop-web/compare/develop...main` and click **Create Pull Request**.
|
||||||
git tag -a v0.2.0 -m "Release v0.2.0: new features and fixes"
|
|
||||||
git push origin v0.2.0
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Gitea Actions** will automatically:
|
4. **Merge the PR** into `main`.
|
||||||
|
|
||||||
|
5. **Drone** will automatically:
|
||||||
- Build the Docker image using the multi-stage Dockerfile
|
- Build the Docker image using the multi-stage Dockerfile
|
||||||
- Tag it with the version (`0.2.0`), minor version (`0.2`), and `latest`
|
- Tag it with the short commit SHA (e.g., `abc1234`) and `main-latest`
|
||||||
- Push all three tags to the Gitea Container Registry
|
- Push both tags to the Gitea Container Registry
|
||||||
|
|
||||||
### Docker image tags
|
### Docker image tags
|
||||||
|
|
||||||
Each release produces three Docker image tags:
|
Each merge into `main` produces two Docker image tags:
|
||||||
|
|
||||||
| Tag | Example | Description |
|
| Tag | Example | Description |
|
||||||
|-----|---------|-------------|
|
|-----|---------|-------------|
|
||||||
| Full version | `gitea.jambotron.com/liosha84/htop-web:0.2.0` | Exact version, use in production |
|
| Commit SHA | `gitea.jambotron.com/liosha84/htop-web:abc1234` | Exact commit, use for reproducibility |
|
||||||
| Minor version | `gitea.jambotron.com/liosha84/htop-web:0.2` | Latest patch of 0.2.x |
|
| Main latest | `gitea.jambotron.com/liosha84/htop-web:main-latest` | Most recent merge into main |
|
||||||
| Latest | `gitea.jambotron.com/liosha84/htop-web:latest` | Most recent stable release |
|
|
||||||
|
|
||||||
### Using a specific version in production
|
### Using a specific version in production
|
||||||
|
|
||||||
In `docker-compose.yml`, always pin to a specific version:
|
In `docker-compose.yml`, pin to a specific commit SHA:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
htop-web:
|
htop-web:
|
||||||
image: gitea.jambotron.com/liosha84/htop-web:0.2.0
|
image: gitea.jambotron.com/liosha84/htop-web:abc1234
|
||||||
```
|
```
|
||||||
|
|
||||||
Avoid using `:latest` in production — it makes rollbacks impossible and breaks reproducibility.
|
Use `main-latest` for development/testing environments. For production, always use the commit SHA tag so you can roll back to a specific version.
|
||||||
|
|
||||||
## Contribution guidelines
|
## Contribution guidelines
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user