Skip to content

Commit 1e7e90c

Browse files
committed
add docker and k8s files
1 parent 176a3c3 commit 1e7e90c

File tree

5 files changed

+165
-0
lines changed

5 files changed

+165
-0
lines changed

.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.git
2+
.github
3+
.gitignore
4+
README.md
5+
k8s
6+
*.md
7+
.env
8+
__pycache__
9+
*.pyc
10+
*.pyo
11+
*.pyd
12+
.Python
13+
*.so
14+
*.egg
15+
*.egg-info
16+
dist
17+
build
18+

.github/workflows/docker-build.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
branches:
12+
- main
13+
- master
14+
workflow_dispatch:
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Log in to Container Registry
35+
if: github.event_name != 'pull_request'
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract metadata (tags, labels) for Docker
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
tags: |
48+
type=ref,event=branch
49+
type=ref,event=pr
50+
type=semver,pattern={{version}}
51+
type=semver,pattern={{major}}.{{minor}}
52+
type=semver,pattern={{major}}
53+
type=sha
54+
type=raw,value=latest,enable={{is_default_branch}}
55+
56+
- name: Build and push Docker image
57+
uses: docker/build-push-action@v5
58+
with:
59+
context: .
60+
file: ./Dockerfile
61+
push: ${{ github.event_name != 'pull_request' }}
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
66+

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
# Copy requirements first for better layer caching
6+
COPY requirements.txt .
7+
8+
# Install Python dependencies
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
# Copy the application code
12+
COPY app.py .
13+
14+
# Make app.py executable
15+
RUN chmod +x app.py
16+
17+
# Run the application
18+
ENTRYPOINT ["python3", "app.py"]
19+
CMD []
20+

k8s/cronjob.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: intune2snipe-secrets
5+
# Note: Replace the placeholder values below with your actual credentials
6+
# Optional: AZURE_GROUP_IDS can be omitted if you don't need group filtering
7+
type: Opaque
8+
stringData:
9+
AZURE_TENANT_ID: "your-tenant-id"
10+
AZURE_CLIENT_ID: "your-client-id"
11+
AZURE_CLIENT_SECRET: "your-client-secret"
12+
SNIPEIT_URL: "https://your-snipeit-url/api/v1"
13+
SNIPEIT_API_TOKEN: "your-snipeit-api-token"
14+
SNIPEIT_DEFAULT_STATUS: "Ready to Deploy"
15+
AZURE_GROUP_IDS: "group-id-1,group-id-2"
16+
---
17+
apiVersion: batch/v1
18+
kind: CronJob
19+
metadata:
20+
name: intune2snipe-sync
21+
namespace: default
22+
spec:
23+
# Run daily at 2:00 AM UTC
24+
schedule: "0 2 * * *"
25+
# Keep last 3 successful jobs and 1 failed job
26+
successfulJobsHistoryLimit: 3
27+
failedJobsHistoryLimit: 1
28+
concurrencyPolicy: Forbid
29+
jobTemplate:
30+
spec:
31+
template:
32+
metadata:
33+
labels:
34+
app: intune2snipe-sync
35+
spec:
36+
restartPolicy: OnFailure
37+
containers:
38+
- name: intune2snipe
39+
# Update with your container registry and image
40+
image: ghcr.io/your-org/your-repo:latest
41+
imagePullPolicy: Always
42+
envFrom:
43+
- secretRef:
44+
name: intune2snipe-secrets
45+
# Optional: Override default platform filter
46+
# args: ["--platform", "windows"]
47+
# Optional: Override group IDs via command-line argument
48+
# args: ["--groups", "group-id-1,group-id-2"]
49+
# Optional: Run in dry-run mode
50+
# args: ["--dry-run"]
51+
resources:
52+
requests:
53+
memory: "128Mi"
54+
cpu: "100m"
55+
limits:
56+
memory: "512Mi"
57+
cpu: "500m"
58+

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
msal>=1.24.0
2+
requests>=2.31.0
3+

0 commit comments

Comments
 (0)