Compare commits
7 Commits
v1.1.2
...
945574906b
| Author | SHA1 | Date | |
|---|---|---|---|
| 945574906b | |||
| ee10a0f35a | |||
| 1ae54a46e7 | |||
| 918fe80566 | |||
| 073a392f19 | |||
| 703ab3b07d | |||
| b2cc478c85 |
@@ -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
|
||||
@@ -1,73 +0,0 @@
|
||||
name: Release Please
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
packages: 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
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"packages": {
|
||||
".": {
|
||||
"release-type": "simple",
|
||||
"version-file": "VERSION"
|
||||
}
|
||||
},
|
||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
".": "1.1.2"
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [1.1.2](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.1...v1.1.2) (2025-11-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* :bug: k3s character limit ([2b91c19](https://github.com/JDB-NET/opnsense-sftp/commit/2b91c19afbf95f9192b43b46ebdc7816bb407db9))
|
||||
|
||||
## [1.1.1](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.0...v1.1.1) (2025-11-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* :bug: allow writing packages ([dbdeacd](https://github.com/JDB-NET/opnsense-sftp/commit/dbdeacdf7de133a0db4c44c13828458ff08a028a))
|
||||
|
||||
## [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
@@ -1,11 +1,9 @@
|
||||
FROM python:3.13-slim
|
||||
LABEL org.opencontainers.image.vendor="JDB-NET"
|
||||
WORKDIR /app
|
||||
|
||||
# Build argument for version
|
||||
ARG VERSION=dev
|
||||
ENV APP_VERSION=${VERSION}
|
||||
|
||||
COPY . /app
|
||||
ARG VERSION=unknown
|
||||
ENV APP_VERSION=${VERSION}
|
||||
RUN pip install -r requirements.txt \
|
||||
&& apt-get update \
|
||||
&& apt-get install curl -y \
|
||||
|
||||
@@ -36,17 +36,15 @@ docker run -d \
|
||||
-e SFTP_PUBLIC_PORT=30222 \
|
||||
-v /path/to/keys:/app/keys \
|
||||
-v /path/to/backups:/app/backups \
|
||||
ghcr.io/jdb-net/opnsense-sftp:latest
|
||||
cr.jdbnet.co.uk/public/opnsense-sftp:latest
|
||||
```
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
opnsense-sftp:
|
||||
image: ghcr.io/jdb-net/opnsense-sftp:latest
|
||||
image: cr.jdbnet.co.uk/public/opnsense-sftp:latest
|
||||
container_name: opnsense-sftp
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
|
||||
@@ -22,22 +22,8 @@ load_dotenv()
|
||||
setup_logging()
|
||||
logger = get_logger(__name__)
|
||||
|
||||
# Read version from VERSION file or environment
|
||||
def get_version():
|
||||
"""Get application version from VERSION file or environment variable."""
|
||||
# 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'
|
||||
return os.getenv('APP_VERSION', 'dev')
|
||||
|
||||
app = Flask(__name__)
|
||||
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'))
|
||||
|
||||
|
||||
@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__':
|
||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
||||
|
||||
|
||||
+23
@@ -279,4 +279,27 @@ class Database:
|
||||
except Error as e:
|
||||
logger.error(f"Error getting instance by ID: {e}")
|
||||
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 []
|
||||
|
||||
|
||||
+7
-7
@@ -15,7 +15,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: opnsense-sftp
|
||||
image: ghcr.io/jdb-net/opnsense-sftp:latest
|
||||
image: cr.jdbnet.co.uk/public/opnsense-sftp:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
@@ -24,7 +24,7 @@ spec:
|
||||
name: "opnsense-sftp"
|
||||
env:
|
||||
- name: DB_HOST
|
||||
value: "10.10.2.27"
|
||||
value: "10.10.25.4"
|
||||
- name: DB_PORT
|
||||
value: "3306"
|
||||
- name: DB_NAME
|
||||
@@ -38,7 +38,7 @@ spec:
|
||||
- name: ADMIN_PASSWORD
|
||||
value: "CVk7QKIB3MjZ8mt6MxES"
|
||||
- name: SFTP_PUBLIC_HOST
|
||||
value: "10.10.2.29"
|
||||
value: "10.10.25.8"
|
||||
- name: SFTP_PUBLIC_PORT
|
||||
value: "30222"
|
||||
volumeMounts:
|
||||
@@ -49,12 +49,12 @@ spec:
|
||||
volumes:
|
||||
- name: keys-volume
|
||||
nfs:
|
||||
server: 10.10.2.5
|
||||
path: /srv/Backups/OPNsense/keys
|
||||
server: 10.10.25.2
|
||||
path: /srv/k3s/opnsense/keys
|
||||
- name: backups-volume
|
||||
nfs:
|
||||
server: 10.10.2.5
|
||||
path: /srv/Backups/OPNsense/backups
|
||||
server: 10.10.25.2
|
||||
path: /srv/k3s/opnsense/backups
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@
|
||||
<p class="text-center text-neutral-400 text-sm">
|
||||
OPNsense Backup Manager
|
||||
{% if version %}
|
||||
<span class="text-neutral-500">v{{ version }}</span>
|
||||
<span class="text-neutral-500">{{ version }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -42,18 +42,11 @@
|
||||
|
||||
<button
|
||||
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
|
||||
</button>
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user