Skip to content

Commit 6accb57

Browse files
committed
feat: initial django-devcontainer setup
0 parents  commit 6accb57

12 files changed

Lines changed: 978 additions & 0 deletions

File tree

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ============================================================
2+
# .dockerignore
3+
# Only docker/ and scripts/ are needed for the image build.
4+
# ============================================================
5+
6+
# Git
7+
.git
8+
.gitignore
9+
.gitattributes
10+
.github
11+
12+
# Docs
13+
*.md
14+
!README.md
15+
docs/
16+
17+
# OS
18+
.DS_Store
19+
Thumbs.db
20+
21+
# Editor
22+
.vscode/
23+
.idea/
24+
*.swp
25+
*~

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Code owners for the repository
2+
# These users will be automatically requested for review on all PRs
3+
4+
* @alihaidar0

.github/dependabot.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: 2
2+
updates:
3+
# ── GitHub Actions ────────────────────────────────────────────────────
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
timezone: "UTC"
11+
target-branch: "main"
12+
rebase-strategy: "auto"
13+
assignees:
14+
- "alihaidar0"
15+
commit-message:
16+
prefix: "ci"
17+
include: "scope"
18+
labels:
19+
- "dependencies"
20+
- "github-actions"
21+
groups:
22+
github-actions-all:
23+
patterns:
24+
- "*"
25+
open-pull-requests-limit: 5
26+
27+
# ── Docker base image ─────────────────────────────────────────────────
28+
- package-ecosystem: "docker"
29+
directory: "/docker"
30+
schedule:
31+
interval: "weekly"
32+
day: "monday"
33+
time: "09:00"
34+
timezone: "UTC"
35+
target-branch: "main"
36+
rebase-strategy: "auto"
37+
assignees:
38+
- "alihaidar0"
39+
commit-message:
40+
prefix: "build"
41+
include: "scope"
42+
labels:
43+
- "dependencies"
44+
- "docker"
45+
open-pull-requests-limit: 3

.github/labels.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
- name: "dependencies"
2+
color: "0075ca"
3+
description: "Automated dependency update opened by Dependabot"
4+
- name: "github-actions"
5+
color: "e4e669"
6+
description: "Updates to GitHub Actions versions in workflow files"
7+
- name: "docker"
8+
color: "0db7ed"
9+
description: "Updates to the Docker base image or Dockerfile"
10+
- name: "breaking change"
11+
color: "d73a4a"
12+
description: "Introduces a breaking change that requires attention before merging"
13+
- name: "bug"
14+
color: "ee0701"
15+
description: "Something is broken or behaving incorrectly"
16+
- name: "enhancement"
17+
color: "84b6eb"
18+
description: "Improvement to an existing feature or behaviour"
19+
- name: "feature"
20+
color: "0e8a16"
21+
description: "Adds new functionality to the image or developer environment"
22+
- name: "chore"
23+
color: "fef2c0"
24+
description: "Maintenance task with no functional impact — cleanup, rename, reorder"
25+
- name: "documentation"
26+
color: "0075ca"
27+
description: "Changes to README, comments, or other documentation only"
28+
- name: "ready for review"
29+
color: "0e8a16"
30+
description: "PR is complete and ready for a review pass"
31+
- name: "work in progress"
32+
color: "e99695"
33+
description: "PR is open for early feedback but is not ready to merge"
34+
- name: "blocked"
35+
color: "d73a4a"
36+
description: "Blocked by another PR, issue, or external dependency"
37+
- name: "on hold"
38+
color: "f9d0c4"
39+
description: "Deliberately paused — not blocked, not abandoned, not yet ready"
40+
- name: "priority: high"
41+
color: "d73a4a"
42+
description: "Should be reviewed and merged within the current week"
43+
- name: "priority: low"
44+
color: "c2e0c6"
45+
description: "No urgency — can be picked up when convenient"
46+
- name: "duplicate"
47+
color: "cccccc"
48+
description: "This issue or PR already exists elsewhere — see linked item"
49+
- name: "wont fix"
50+
color: "ffffff"
51+
description: "Acknowledged but intentionally out of scope for this repo"
52+
- name: "good first issue"
53+
color: "7057ff"
54+
description: "Suitable for a first contribution — well scoped and documented"

.github/workflows/docker.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# ============================================================
2+
# .github/workflows/docker.yml
3+
#
4+
# Builds the Django dev container image and pushes to Docker Hub.
5+
# Cross-platform: linux/amd64 (Windows/Linux) + linux/arm64 (Apple Silicon)
6+
#
7+
# Triggers:
8+
# - Push to main → builds + pushes :latest + :sha-xxx
9+
# - PR targeting main → builds only (no push) — validates Dockerfile
10+
# - Manual dispatch → optional push, optional force rebuild
11+
#
12+
# Required GitHub Secrets:
13+
# DOCKERHUB_USERNAME Docker Hub username
14+
# DOCKERHUB_TOKEN Docker Hub access token (Read/Write)
15+
#
16+
# Platforms:
17+
# linux/amd64 — Windows / Linux / GCP
18+
# linux/arm64 — Apple Silicon Macs
19+
# ============================================================
20+
21+
name: Docker
22+
23+
on:
24+
push:
25+
branches:
26+
- main
27+
paths:
28+
- "docker/Dockerfile.dev"
29+
- "scripts/**"
30+
- ".github/workflows/docker.yml"
31+
32+
pull_request:
33+
branches:
34+
- main
35+
paths:
36+
- "docker/Dockerfile.dev"
37+
- "scripts/**"
38+
- ".github/workflows/docker.yml"
39+
40+
workflow_dispatch:
41+
inputs:
42+
push_image:
43+
description: "Push image to Docker Hub?"
44+
required: true
45+
default: "true"
46+
type: choice
47+
options:
48+
- "true"
49+
- "false"
50+
force_rebuild:
51+
description: "Bypass layer cache (full rebuild)"
52+
required: false
53+
type: boolean
54+
default: false
55+
56+
concurrency:
57+
group: docker-${{ github.ref }}
58+
cancel-in-progress: false
59+
60+
env:
61+
IMAGE_NAME: alihaidar199527/django-devcontainer
62+
63+
jobs:
64+
65+
build-and-push:
66+
name: Build & Push Dev Image
67+
runs-on: ubuntu-latest
68+
69+
permissions:
70+
contents: read
71+
72+
steps:
73+
74+
- name: Checkout
75+
uses: actions/checkout@v6
76+
77+
- name: Set up QEMU
78+
uses: docker/setup-qemu-action@v4
79+
80+
- name: Set up Docker Buildx
81+
uses: docker/setup-buildx-action@v4
82+
83+
- name: Log in to Docker Hub
84+
# Skip login on PR builds — we are not pushing, no credentials needed
85+
if: github.event_name != 'pull_request'
86+
uses: docker/login-action@v4
87+
with:
88+
username: ${{ secrets.DOCKERHUB_USERNAME }}
89+
password: ${{ secrets.DOCKERHUB_TOKEN }}
90+
91+
- name: Extract image metadata
92+
id: meta
93+
uses: docker/metadata-action@v6
94+
with:
95+
images: ${{ env.IMAGE_NAME }}
96+
tags: |
97+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
98+
type=sha,prefix=sha-,format=short
99+
100+
- name: Build and push
101+
id: build
102+
uses: docker/build-push-action@v7
103+
with:
104+
context: .
105+
file: docker/Dockerfile.dev
106+
platforms: linux/amd64,linux/arm64
107+
# Push only on a real push to main or an approved manual dispatch
108+
# PR builds compile the image to validate it but never push
109+
push: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_image == 'true') }}
110+
tags: ${{ steps.meta.outputs.tags }}
111+
labels: ${{ steps.meta.outputs.labels }}
112+
cache-from: type=gha
113+
cache-to: type=gha,mode=max
114+
no-cache: ${{ inputs.force_rebuild == true }}
115+
provenance: true
116+
sbom: true
117+
118+
- name: Write job summary
119+
if: always()
120+
run: |
121+
echo "## 🐳 Docker Build Summary" >> $GITHUB_STEP_SUMMARY
122+
echo "" >> $GITHUB_STEP_SUMMARY
123+
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
124+
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
125+
echo "| **Image** | \`${{ env.IMAGE_NAME }}\` |" >> $GITHUB_STEP_SUMMARY
126+
echo "| **Digest** | \`${{ steps.build.outputs.digest }}\` |" >> $GITHUB_STEP_SUMMARY
127+
echo "| **Tags** | \`${{ steps.meta.outputs.tags }}\` |" >> $GITHUB_STEP_SUMMARY
128+
echo "| **Platforms** | \`linux/amd64, linux/arm64\` |" >> $GITHUB_STEP_SUMMARY
129+
echo "| **Triggered by** | \`${{ github.event_name }}\` on \`${{ github.ref_name }}\` |" >> $GITHUB_STEP_SUMMARY
130+
echo "| **Commit** | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
131+
echo "| **Pushed to Docker Hub** | \`${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_image == 'true') }}\` |" >> $GITHUB_STEP_SUMMARY
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# ============================================================
2+
# .github/workflows/dockerhub-description.yml
3+
#
4+
# Syncs README.md to the Docker Hub repository description.
5+
#
6+
# Triggers:
7+
# - Push to main where README.md changed → updates Docker Hub if image exists
8+
# - PR targeting main where README.md changed → updates Docker Hub if image exists
9+
# - Manual dispatch → updates Docker Hub if image exists
10+
#
11+
# Behaviour:
12+
# - Checks if the image exists on Docker Hub before updating
13+
# - Skips silently (no error) if the image does not exist yet
14+
#
15+
# Required GitHub Secrets:
16+
# DOCKERHUB_USERNAME Docker Hub username
17+
# DOCKERHUB_TOKEN Docker Hub access token (Read/Write)
18+
# ============================================================
19+
20+
name: Docker Hub description
21+
on:
22+
push:
23+
branches:
24+
- main
25+
paths:
26+
- "README.md"
27+
pull_request:
28+
branches:
29+
- main
30+
paths:
31+
- "README.md"
32+
workflow_dispatch:
33+
jobs:
34+
update-description:
35+
name: Update Docker Hub description
36+
runs-on: ubuntu-latest
37+
permissions:
38+
contents: read
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v6
42+
with:
43+
sparse-checkout: README.md
44+
- name: Check image exists on Docker Hub
45+
id: check
46+
run: |
47+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
48+
https://hub.docker.com/v2/repositories/${{ secrets.DOCKERHUB_USERNAME }}/django-devcontainer/)
49+
if [ "$STATUS" = "200" ]; then
50+
echo "exists=true" >> $GITHUB_OUTPUT
51+
else
52+
echo "exists=false" >> $GITHUB_OUTPUT
53+
fi
54+
- name: Update Docker Hub description
55+
if: steps.check.outputs.exists == 'true'
56+
uses: peter-evans/dockerhub-description@v5
57+
with:
58+
username: ${{ secrets.DOCKERHUB_USERNAME }}
59+
password: ${{ secrets.DOCKERHUB_TOKEN }}
60+
repository: ${{ secrets.DOCKERHUB_USERNAME }}/django-devcontainer
61+
readme-filepath: ./README.md
62+
- name: Write job summary
63+
if: always()
64+
run: |
65+
echo "## 📄 Docker Hub Description Summary" >> $GITHUB_STEP_SUMMARY
66+
echo "" >> $GITHUB_STEP_SUMMARY
67+
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
68+
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
69+
echo "| **Triggered by** | \`${{ github.event_name }}\` on \`${{ github.ref_name }}\` |" >> $GITHUB_STEP_SUMMARY
70+
echo "| **Commit** | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
71+
echo "| **Image exists** | \`${{ steps.check.outputs.exists }}\` |" >> $GITHUB_STEP_SUMMARY
72+
echo "| **Docker Hub updated** | \`${{ steps.check.outputs.exists }}\` |" >> $GITHUB_STEP_SUMMARY

.github/workflows/labels.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Labels
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/labels.yml"
9+
workflow_dispatch:
10+
11+
jobs:
12+
sync:
13+
name: Sync labels to GitHub
14+
runs-on: ubuntu-latest
15+
permissions:
16+
issues: write
17+
contents: read
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v6
21+
with:
22+
sparse-checkout: .github/labels.yml
23+
- name: Sync labels
24+
uses: EndBug/label-sync@v2
25+
with:
26+
config-file: .github/labels.yml
27+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# OS
2+
.DS_Store
3+
Thumbs.db
4+
Desktop.ini
5+
6+
# Editor
7+
.vscode/settings.json
8+
.idea/
9+
*.swp
10+
*~
11+
12+
# Secrets
13+
.env
14+
.env.*
15+
!.env.example
16+
17+
django-devcontainer-code.xml

0 commit comments

Comments
 (0)