13 Commits

Author SHA1 Message Date
jamie 945574906b Merge pull request 'chore: remove release-please configuration and related files' (#9) from v1.2.1 into main
Reviewed-on: #9
2026-01-08 17:43:52 +00:00
jamie ee10a0f35a chore: remove release-please configuration and related files
Release / release (pull_request) Successful in 26s
Release / Deploy to Kubernetes (pull_request) Successful in 1s
2026-01-08 17:43:33 +00:00
jamie 1ae54a46e7 build: 🚀 redeploy 2025-12-20 13:21:06 +00:00
Jamie 918fe80566 Merge pull request #4 from JDB-NET/release-please--branches--main
chore(main): release 1.2.0
2025-11-01 17:05:01 +00:00
github-actions[bot] 073a392f19 chore(main): release 1.2.0 2025-11-01 17:04:09 +00:00
jamie 703ab3b07d feat: latest backup api endpoint - /api/backups/latest 2025-11-01 16:53:32 +00:00
jamie b2cc478c85 refactor: 🎨 tidy login page 2025-11-01 16:48:28 +00:00
Jamie ac90952499 Merge pull request #3 from JDB-NET/release-please--branches--main
chore(main): release 1.1.2
2025-11-01 16:19:12 +00:00
github-actions[bot] dcea388b6f chore(main): release 1.1.2 2025-11-01 16:17:47 +00:00
jamie 2b91c19afb fix: 🐛 k3s character limit 2025-11-01 16:17:29 +00:00
Jamie bac62a1577 Merge pull request #2 from JDB-NET/release-please--branches--main
chore(main): release 1.1.1
2025-11-01 16:11:09 +00:00
github-actions[bot] c39b51c070 chore(main): release 1.1.1 2025-11-01 16:10:48 +00:00
jamie dbdeacdf7d fix: 🐛 allow writing packages 2025-11-01 16:10:30 +00:00
13 changed files with 120 additions and 146 deletions
+60
View File
@@ -0,0 +1,60 @@
name: Release
on:
pull_request:
branches:
- main
types: [closed]
jobs:
release:
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'v')
runs-on: build-htz-01
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract Version
id: get_version
run: echo "VERSION=${{ github.head_ref }}" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: changelog
uses: https://github.com/metcalfc/changelog-generator@v4.6.2
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
docker build -t cr.jdbnet.co.uk/public/opnsense-sftp:$VERSION \
-t cr.jdbnet.co.uk/public/opnsense-sftp:latest \
--build-arg VERSION=$VERSION \
.
docker push cr.jdbnet.co.uk/public/opnsense-sftp:$VERSION
docker push cr.jdbnet.co.uk/public/opnsense-sftp:latest
- name: Create Gitea Release
uses: https://gitea.com/actions/gitea-release-action@v1
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
name: ${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
deploy:
name: Deploy to Kubernetes
needs: release
runs-on: k3s-internal-htz-01
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy to Kubernetes
run: |
sudo kubectl replace -f deployment.yml --grace-period=60 --force
-72
View File
@@ -1,72 +0,0 @@
name: Release Please
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
manifest-file: .release-please-manifest.json
config-file: .release-please-config.json
- name: Checkout
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4
- name: Set up Docker Buildx
if: ${{ steps.release.outputs.release_created }}
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: ${{ steps.release.outputs.release_created }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Read version
if: ${{ steps.release.outputs.release_created }}
id: version
run: |
VERSION=$(cat VERSION)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build and push Docker image
if: ${{ steps.release.outputs.release_created }}
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/jdb-net/opnsense-sftp:${{ env.VERSION }}
ghcr.io/jdb-net/opnsense-sftp:latest
build-args: |
VERSION=${{ env.VERSION }}
deploy:
name: Deploy to Kubernetes
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: [ k3s-lan-01 ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Apply manifests
run: |
sudo kubectl replace -f deployment.yml --grace-period=60 --force
-10
View File
@@ -1,10 +0,0 @@
{
"packages": {
".": {
"release-type": "simple",
"version-file": "VERSION"
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
-4
View File
@@ -1,4 +0,0 @@
{
".": "1.1.0"
}
-14
View File
@@ -1,14 +0,0 @@
# Changelog
## [1.1.0](https://github.com/JDB-NET/opnsense-sftp/compare/v1.0.0...v1.1.0) (2025-11-01)
### Features
* :sparkles: initial commit ([07fc785](https://github.com/JDB-NET/opnsense-sftp/commit/07fc78592bc83e500ae0f3312d8a7bae9b0bf1f9))
### Bug Fixes
* :bug: public host ip ([6dd09cf](https://github.com/JDB-NET/opnsense-sftp/commit/6dd09cf147f7a20856af1cfa68390586f6acc2e5))
* :bug: release please config ([89e1231](https://github.com/JDB-NET/opnsense-sftp/commit/89e12315fe69a64849068645048b01c871165532))
+3 -5
View File
@@ -1,11 +1,9 @@
FROM python:3.13-slim FROM python:3.13-slim
LABEL org.opencontainers.image.vendor="JDB-NET"
WORKDIR /app WORKDIR /app
# Build argument for version
ARG VERSION=dev
ENV APP_VERSION=${VERSION}
COPY . /app COPY . /app
ARG VERSION=unknown
ENV APP_VERSION=${VERSION}
RUN pip install -r requirements.txt \ RUN pip install -r requirements.txt \
&& apt-get update \ && apt-get update \
&& apt-get install curl -y \ && apt-get install curl -y \
+2 -4
View File
@@ -36,17 +36,15 @@ docker run -d \
-e SFTP_PUBLIC_PORT=30222 \ -e SFTP_PUBLIC_PORT=30222 \
-v /path/to/keys:/app/keys \ -v /path/to/keys:/app/keys \
-v /path/to/backups:/app/backups \ -v /path/to/backups:/app/backups \
ghcr.io/jdb-net/opnsense-sftp:latest cr.jdbnet.co.uk/public/opnsense-sftp:latest
``` ```
### Docker Compose ### Docker Compose
```yaml ```yaml
version: '3.8'
services: services:
opnsense-sftp: opnsense-sftp:
image: ghcr.io/jdb-net/opnsense-sftp:latest image: cr.jdbnet.co.uk/public/opnsense-sftp:latest
container_name: opnsense-sftp container_name: opnsense-sftp
restart: unless-stopped restart: unless-stopped
ports: ports:
-1
View File
@@ -1 +0,0 @@
1.1.0
+18 -15
View File
@@ -22,22 +22,8 @@ load_dotenv()
setup_logging() setup_logging()
logger = get_logger(__name__) logger = get_logger(__name__)
# Read version from VERSION file or environment
def get_version(): def get_version():
"""Get application version from VERSION file or environment variable.""" return os.getenv('APP_VERSION', 'dev')
# Check environment variable first (set during Docker build)
env_version = os.getenv('APP_VERSION')
if env_version and env_version != 'dev':
return env_version
# Fall back to VERSION file
try:
version_path = Path(__file__).parent / 'VERSION'
if version_path.exists():
return version_path.read_text().strip()
except Exception:
pass
return 'dev'
app = Flask(__name__) app = Flask(__name__)
app.secret_key = os.getenv('SECRET_KEY', 'change-this-secret-key-in-production') app.secret_key = os.getenv('SECRET_KEY', 'change-this-secret-key-in-production')
@@ -342,6 +328,23 @@ def delete_backup(backup_id):
return redirect(url_for('backups')) return redirect(url_for('backups'))
@app.route('/api/backups/latest')
def api_latest_backups():
"""API endpoint to get the latest backup date and time for each instance."""
latest_backups = db.get_latest_backup_per_instance()
# Format the response
result = []
for item in latest_backups:
result.append({
'instance_id': item['instance_id'],
'instance_name': item['instance_name'],
'latest_backup': item['latest_backup'].isoformat() if item['latest_backup'] else None
})
return jsonify(result)
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True) app.run(host='0.0.0.0', port=5000, debug=True)
+23
View File
@@ -279,4 +279,27 @@ class Database:
except Error as e: except Error as e:
logger.error(f"Error getting instance by ID: {e}") logger.error(f"Error getting instance by ID: {e}")
return None return None
def get_latest_backup_per_instance(self) -> List[Dict[str, Any]]:
"""Get the latest backup date and time for each instance."""
try:
with self.get_connection() as conn:
cursor = conn.cursor(dictionary=True)
cursor.execute("""
SELECT
o.id as instance_id,
o.name as instance_name,
o.identifier as instance_identifier,
MAX(b.uploaded_at) as latest_backup
FROM opnsense_instances o
LEFT JOIN backups b ON o.id = b.instance_id
GROUP BY o.id, o.name, o.identifier
ORDER BY o.name
""")
results = cursor.fetchall()
cursor.close()
return results
except Error as e:
logger.error(f"Error getting latest backup per instance: {e}")
return []
+12 -12
View File
@@ -15,16 +15,16 @@ spec:
spec: spec:
containers: containers:
- name: opnsense-sftp - name: opnsense-sftp
image: ghcr.io/jdb-net/opnsense-sftp:latest image: cr.jdbnet.co.uk/public/opnsense-sftp:latest
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 5000 - containerPort: 5000
name: "opnsense-sftp" name: "opnsense-web"
- containerPort: 2222 - containerPort: 2222
name: "opnsense-sftp-sftp" name: "opnsense-sftp"
env: env:
- name: DB_HOST - name: DB_HOST
value: "10.10.2.27" value: "10.10.25.4"
- name: DB_PORT - name: DB_PORT
value: "3306" value: "3306"
- name: DB_NAME - name: DB_NAME
@@ -38,7 +38,7 @@ spec:
- name: ADMIN_PASSWORD - name: ADMIN_PASSWORD
value: "CVk7QKIB3MjZ8mt6MxES" value: "CVk7QKIB3MjZ8mt6MxES"
- name: SFTP_PUBLIC_HOST - name: SFTP_PUBLIC_HOST
value: "10.10.2.29" value: "10.10.25.8"
- name: SFTP_PUBLIC_PORT - name: SFTP_PUBLIC_PORT
value: "30222" value: "30222"
volumeMounts: volumeMounts:
@@ -49,17 +49,17 @@ spec:
volumes: volumes:
- name: keys-volume - name: keys-volume
nfs: nfs:
server: 10.10.2.5 server: 10.10.25.2
path: /srv/Backups/OPNsense/keys path: /srv/k3s/opnsense/keys
- name: backups-volume - name: backups-volume
nfs: nfs:
server: 10.10.2.5 server: 10.10.25.2
path: /srv/Backups/OPNsense/backups path: /srv/k3s/opnsense/backups
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: opnsense-sftp-ingress-service name: opnsense-web-ingress-service
namespace: opnsense-sftp namespace: opnsense-sftp
spec: spec:
selector: selector:
@@ -73,7 +73,7 @@ spec:
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: opnsense-sftp-sftp-service name: opnsense-sftp-service
namespace: opnsense-sftp namespace: opnsense-sftp
spec: spec:
type: NodePort type: NodePort
@@ -100,7 +100,7 @@ spec:
path: "/" path: "/"
backend: backend:
service: service:
name: opnsense-sftp-ingress-service name: opnsense-web-ingress-service
port: port:
number: 80 number: 80
--- ---
+1 -1
View File
@@ -60,7 +60,7 @@
<p class="text-center text-neutral-400 text-sm"> <p class="text-center text-neutral-400 text-sm">
OPNsense Backup Manager OPNsense Backup Manager
{% if version %} {% if version %}
<span class="text-neutral-500">v{{ version }}</span> <span class="text-neutral-500">{{ version }}</span>
{% endif %} {% endif %}
</p> </p>
</div> </div>
+1 -8
View File
@@ -42,18 +42,11 @@
<button <button
type="submit" type="submit"
class="w-full bg-orange-500 hover:bg-orange-600 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200" class="w-full bg-orange-500 hover:bg-orange-600 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200 hover:cursor-pointer">
>
Sign In Sign In
</button> </button>
</form> </form>
<div class="mt-6 p-4 bg-neutral-700 rounded-md">
<p class="text-xs text-neutral-400">
Default credentials: <code class="text-orange-400">admin / admin</code>
<br>Please change these after first login!
</p>
</div>
</div> </div>
</div> </div>
</div> </div>