Skip to content

Commit 16dea86

Browse files
author
developer
committed
Add Docker support with Dockerfile, docker-compose, and deployment script
1 parent 51e7723 commit 16dea86

File tree

8 files changed

+659
-322
lines changed

8 files changed

+659
-322
lines changed

.dockerignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# Documentation
7+
README.md
8+
*.md
9+
docs/
10+
11+
# CI/CD
12+
.github/
13+
.gitlab-ci.yml
14+
15+
# IDE
16+
.vscode/
17+
.idea/
18+
*.swp
19+
*.swo
20+
21+
# OS
22+
.DS_Store
23+
Thumbs.db
24+
25+
# Logs
26+
logs/
27+
*.log
28+
29+
# Dependencies
30+
node_modules/
31+
npm-debug.log*
32+
33+
# Environment
34+
.env
35+
.env.local
36+
.env.example
37+
38+
# Docker
39+
Dockerfile
40+
docker-compose.yml
41+
.dockerignore
42+
43+
# Scripts
44+
deploy.sh
45+
*.sh
46+
47+
# Temporary files
48+
tmp/
49+
temp/
50+
*.tmp

.env.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# CIAO-CORS Environment Configuration
2+
3+
# Basic Settings
4+
PORT=8038
5+
ADMIN_PASSWORD=your-secure-password-here
6+
7+
# CORS Configuration
8+
ALLOWED_ORIGINS=*
9+
BLOCKED_ORIGINS=
10+
ALLOWED_IPS=
11+
BLOCKED_IPS=
12+
13+
# Rate Limiting
14+
RATE_LIMIT_PER_MINUTE=60
15+
MAX_CONCURRENT=10
16+
REQUIRE_AUTH=false
17+
18+
# Advanced Configuration (JSON format)
19+
# CIAO_CORS_CONFIG={"allowedOrigins":["*"],"rateLimit":{"requestsPerMinute":60}}

.github/workflows/docker.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main, master ]
9+
10+
env:
11+
DOCKER_IMAGE: bestzwei/ciao-cors
12+
DOCKERHUB_USERNAME: bestzwei
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Login to DockerHub
26+
if: github.event_name != 'pull_request'
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ env.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_TOKEN }}
31+
32+
- name: Extract metadata
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ${{ env.DOCKER_IMAGE }}
37+
tags: |
38+
type=ref,event=branch
39+
type=ref,event=pr
40+
type=semver,pattern={{version}}
41+
type=semver,pattern={{major}}.{{minor}}
42+
type=semver,pattern={{major}}
43+
type=raw,value=latest,enable={{is_default_branch}}
44+
45+
- name: Build and push
46+
uses: docker/build-push-action@v5
47+
with:
48+
context: .
49+
platforms: linux/amd64,linux/arm64
50+
push: ${{ github.event_name != 'pull_request' }}
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max
55+
56+
- name: Update repo description
57+
if: github.event_name != 'pull_request'
58+
uses: peter-evans/dockerhub-description@v3
59+
with:
60+
username: ${{ env.DOCKERHUB_USERNAME }}
61+
password: ${{ secrets.DOCKERHUB_TOKEN }}
62+
repository: ${{ env.DOCKER_IMAGE }}
63+
short-description: "CIAO-CORS - Comprehensive CORS Proxy with Web Management Interface"
64+
readme-filepath: ./README.md

.gitignore

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,42 @@ build/
2121
logs
2222
*.log
2323
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
2426

25-
# Editor directories
26-
.idea/
27+
# Runtime data
28+
pids
29+
*.pid
30+
*.seed
31+
*.pid.lock
32+
33+
# Environment variables
34+
.env
35+
.env.local
36+
.env.production
37+
.env.test
38+
39+
# IDE
2740
.vscode/
41+
.idea/
2842
*.swp
2943
*.swo
44+
*~
3045

31-
# OS
46+
# OS generated files
3247
.DS_Store
48+
.DS_Store?
49+
._*
50+
.Spotlight-V100
51+
.Trashes
52+
ehthumbs.db
3353
Thumbs.db
54+
55+
# Temporary files
56+
tmp/
57+
temp/
58+
*.tmp
59+
*.temp
60+
61+
# Docker
62+
.docker/

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM denoland/deno:1.40.2
2+
3+
# Set the working directory
4+
WORKDIR /app
5+
6+
# Copy the main TypeScript file
7+
COPY main.ts .
8+
9+
# Cache dependencies (if any)
10+
RUN deno cache main.ts
11+
12+
# Expose port 8038
13+
EXPOSE 8038
14+
15+
# Set environment variables
16+
ENV PORT=8038
17+
ENV ADMIN_PASSWORD=admin123
18+
19+
# Create a non-root user
20+
RUN groupadd -r denouser && useradd -r -g denouser denouser
21+
RUN chown -R denouser:denouser /app
22+
USER denouser
23+
24+
# Health check
25+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
26+
CMD deno eval "const response = await fetch('http://localhost:8038/'); console.log('Health check:', response.status === 200 ? 'OK' : 'FAIL'); Deno.exit(response.status === 200 ? 0 : 1);"
27+
28+
# Start the application
29+
CMD ["deno", "run", "--allow-net", "--allow-env", "main.ts"]

0 commit comments

Comments
 (0)