Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
njavilas2015 committed Nov 7, 2024
1 parent 36a91b7 commit 5b8e01c
Show file tree
Hide file tree
Showing 23 changed files with 1,378 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:

- name: Build Docker image
run: |
docker build -t njavilas/qlub:latest .
docker build -t njavilas/qlub:server .
- name: Push Docker image
run: |
docker push njavilas/qlub:latest
docker push njavilas/qlub:server
44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,39 +57,65 @@ El archivo de configuración JSON debe contener una lista de subdominios. Cada s
```json
[
{
"name": "domain.com",
"name": "onbbu.ar",
"location": [
{
"name": "frontend",
"ssl": true,
"path": "/",
"port": "443",
"instances": [
"site_docker_1",
"site_server_2"
"site"
]
},
{
"name": "backend",
"ssl": false,
"path": "/api",
"port": "8000",
"instances": [
"api_docker_1",
"api_server_2"
"qlub"
]
}
],
"ssl": true,
"ssl_cert": "/etc/letsencrypt/fullchain.pem",
"ssl_cert_key": "/etc/letsencrypt/privkey.pem"
"ssl_cert": "/etc/letsencrypt/live/npm-11/fullchain.pem",
"ssl_cert_key": "/etc/letsencrypt/live/npm-11/privkey.pem"
}
]
```

## Docker Compose
Puedes descargar la imagen lista para trabajar `docker pull njavilas/qlub:latest`
Puedes descargar la imagen lista para trabajar `docker pull njavilas/qlub:server`

```yml
services:
proxy:
image: nginx:alpine
ports:
- 80:80
- 443:443

volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- /mnt/md0/data/letsencrypt/:/etc/letsencrypt/

depends_on:
- site
- qlub

site:
image: njavilas/qlub:site

volumes:
- /mnt/md0/data/letsencrypt/live/npm-42/fullchain.pem:/etc/letsencrypt/fullchain.pem
- /mnt/md0/data/letsencrypt/live/npm-42/privkey.pem:/etc/letsencrypt/privkey.pem

expose:
- 443

qlub:
image: njavilas/qlub:latest
image: njavilas/qlub:server
volumes:
- ./subdomains.json:/app/subdomains.json
- ./nginx.conf:/app/nginx.conf
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
docker build -t njavilas/qlub:latest .
docker build -t njavilas/qlub:server .
docker push njavilas/qlub:server
30 changes: 18 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@ services:
proxy:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
- 80:80
- 443:443

volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- /mnt/md0/data/letsencrypt/:/etc/letsencrypt/

networks:
onbbu:
aliases:
- proxy.onbbu.ar
depends_on:
- site
- qlub

site:
image: njavilas/qlub:site

volumes:
- /mnt/md0/data/letsencrypt/live/npm-42/fullchain.pem:/etc/letsencrypt/fullchain.pem
- /mnt/md0/data/letsencrypt/live/npm-42/privkey.pem:/etc/letsencrypt/privkey.pem

expose:
- 443

qlub:
image: njavilas/qlub:1.0
image: njavilas/qlub:server
volumes:
- ./subdomains.json:/app/subdomains.json
- ./nginx.conf:/app/nginx.conf

networks:
company:
name: company_new
- ./nginx.conf:/app/nginx.conf
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module github.com/njavilas2015/qlub
go 1.23.2

require (
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
golang.org/x/sys v0.13.0 // indirect
)
22 changes: 22 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/meilisearch/meilisearch-go v0.29.0 h1:HZ9NEKN59USINQ/DXJge/aaXq8IrsKbXGTdAoBaaDz4=
github.com/meilisearch/meilisearch-go v0.29.0/go.mod h1:2cRCAn4ddySUsFfNDLVPod/plRibQsJkXF/4gLhxbOk=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 3 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import (
)

type Location struct {
Alias string `json:"alias"`
Path string `json:"path"`
Port string `json:"port"`
Instances []string `json:"instances"`
Ssl bool `json:"ssl"`
}

type Subdomain struct {
Name string `json:"name"`
Domain string `json:"domain"`
Location []Location `json:"location"`
Ssl bool `json:"ssl"`
SslCert string `json:"ssl_cert"`
Expand Down
20 changes: 11 additions & 9 deletions internal/config/templates.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package config

const NginxTemplate = `http {
# Define common proxy headers
map $http_upgrade upgrade;
map $connection connection;
const NginxTemplate = `events {
}
http {
{{- range $subdomain := . }}
{{- range $location := $subdomain.Location }}
upstream {{$subdomain.Name}}_{{ $location.Path }}_upstream {
upstream {{ $location.Alias }}_upstream {
{{- range $instances := $location.Instances }}
server {{ $instances }}:{{ $location.Port }};
{{- end }}
Expand All @@ -25,20 +25,22 @@ const NginxTemplate = `http {
listen 80;
{{- end }}
server_name {{ $subdomain.Name }};
server_name {{ $subdomain.Domain }};
{{- range $location := $subdomain.Location }}
location {{ $location.Path }} {
{{- if $subdomain.Ssl }}
proxy_pass https://{{$subdomain.Name}}_{{ $location.Path }}_upstream;
{{- if $location.Ssl }}
proxy_pass https://{{ $location.Alias }}_upstream;
{{- else }}
proxy_pass http://{{$subdomain.Name}}_{{ $location.Path }}_upstream;
proxy_pass http://{{ $location.Alias }}_upstream;
{{- end }}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
}
{{- end }}
}
Expand Down
5 changes: 5 additions & 0 deletions site/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
.git
pnpm-lock.yaml
Dockerfile
24 changes: 24 additions & 0 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
22 changes: 22 additions & 0 deletions site/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:23-alpine3.19 AS builder

WORKDIR /app

COPY package.json /app/package.json

RUN npm install

COPY . .

RUN npm run build

FROM nginx:stable

COPY --from=builder /app/dist /usr/share/nginx/html

COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80
EXPOSE 443

CMD ["nginx", "-g", "daemon off;"]
2 changes: 2 additions & 0 deletions site/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker build -t njavilas/qlub:site .
docker push njavilas/qlub:site
13 changes: 13 additions & 0 deletions site/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>QLUB App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
19 changes: 19 additions & 0 deletions site/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "qlub",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.24.3"
},
"devDependencies": {
"@preact/preset-vite": "^2.9.1",
"typescript": "~5.6.2",
"vite": "^5.4.10"
}
}
Loading

0 comments on commit 5b8e01c

Please sign in to comment.