Compare commits
2 Commits
e0d81c061b
...
ff1d01828d
Author | SHA1 | Date | |
---|---|---|---|
ff1d01828d | |||
851f5d64cc |
9
.dockerignore
Normal file
9
.dockerignore
Normal file
@ -0,0 +1,9 @@
|
||||
/admin-key.json
|
||||
/config.yml
|
||||
/tools
|
||||
/out
|
||||
/dist
|
||||
/data
|
||||
/bin
|
||||
/.bouncer-token
|
||||
/.env
|
15
Dockerfile
15
Dockerfile
@ -1,4 +1,4 @@
|
||||
FROM golang:1.19 AS BUILD
|
||||
FROM golang:1.20 AS BUILD
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y make
|
||||
@ -19,12 +19,17 @@ RUN mkdir -p /usr/local/bin \
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
|
||||
|
||||
COPY --from=BUILD /src/dist/bouncer_linux_amd64_v1 /app
|
||||
COPY --from=BUILD /src/config.yml /etc/bouncer/config.yml
|
||||
RUN mkdir -p /usr/local/bin /usr/share/bouncer/bin /etc/bouncer
|
||||
|
||||
COPY --from=BUILD /src/dist/bouncer_linux_amd64_v1/bouncer /usr/share/bouncer/bin/bouncer
|
||||
|
||||
RUN ln -s /usr/share/bouncer/bin/bouncer /usr/local/bin/bouncer \
|
||||
&& /usr/share/bouncer/bin/bouncer -c '' config dump > /etc/bouncer/config.yml
|
||||
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
ENTRYPOINT ["/app/bouncer"]
|
||||
ENV BOUNCER_WORKDIR=/usr/share/bouncer
|
||||
ENV BOUNCER_CONFIG=/etc/bouncer/config.yml
|
||||
|
||||
CMD ["bouncer", "run", "-c", "/etc/bouncer/config.yml"]
|
||||
CMD ["bouncer"]
|
21
Makefile
21
Makefile
@ -5,11 +5,11 @@ GITCHLOG_ARGS ?=
|
||||
SHELL := /bin/bash
|
||||
|
||||
BOUNCER_VERSION ?=
|
||||
GIT_VERSION := $(shell git describe --always)
|
||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
DATE_VERSION := $(shell date +%Y.%-m.%-d)
|
||||
FULL_VERSION := v$(DATE_VERSION)-$(GIT_VERSION)$(if $(shell git diff --stat),-dirty,)
|
||||
FULL_VERSION := v$(DATE_VERSION)-$(GIT_COMMIT)$(if $(shell git diff --stat),-dirty,)
|
||||
|
||||
DOCKER_IMAGE_NAME ?= cadoles/bouncer
|
||||
DOCKER_IMAGE_NAME ?= reg.cadoles.com/cadoles/bouncer
|
||||
DOCKER_IMAGE_TAG ?= $(FULL_VERSION)
|
||||
|
||||
GOTEST_ARGS ?= -short
|
||||
@ -25,16 +25,6 @@ test: test-go ## Executing tests
|
||||
test-go: deps
|
||||
( set -o allexport && source .env && set +o allexport && go test -v -count=1 $(GOTEST_ARGS) ./... )
|
||||
|
||||
test-install-script: tools/bin/bash_unit
|
||||
tools/bin/bash_unit ./misc/script/test_install.sh
|
||||
|
||||
tools/bin/bash_unit:
|
||||
mkdir -p tools/bin
|
||||
cd tools/bin && bash <(curl -s https://raw.githubusercontent.com/pgrange/bash_unit/master/install.sh)
|
||||
|
||||
lint: ## Lint sources code
|
||||
golangci-lint run --enable-all $(LINT_ARGS)
|
||||
|
||||
build: build-bouncer ## Build artefacts
|
||||
|
||||
build-bouncer: deps ## Build executable
|
||||
@ -83,9 +73,6 @@ finish-release:
|
||||
git push --all
|
||||
git push --tags
|
||||
|
||||
install-git-hooks:
|
||||
git config core.hooksPath .githooks
|
||||
|
||||
docker-build:
|
||||
docker build -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) .
|
||||
|
||||
@ -106,7 +93,7 @@ gitea-release: tools/gitea-release/bin/gitea-release.sh goreleaser
|
||||
GITEA_RELEASE_BASE_URL="https://forge.cadoles.com" \
|
||||
GITEA_RELEASE_VERSION="$(FULL_VERSION)" \
|
||||
GITEA_RELEASE_NAME="$(FULL_VERSION)" \
|
||||
GITEA_RELEASE_COMMITISH_TARGET="$(GIT_VERSION)" \
|
||||
GITEA_RELEASE_COMMITISH_TARGET="$(GIT_COMMIT)" \
|
||||
GITEA_RELEASE_IS_DRAFT="false" \
|
||||
GITEA_RELEASE_BODY="" \
|
||||
GITEA_RELEASE_ATTACHMENTS="$$(find .gitea-release/* -type f)" \
|
||||
|
@ -16,4 +16,5 @@
|
||||
|
||||
### Développement
|
||||
|
||||
- [(FR) - Démarrer avec les sources](./fr/tutorials/getting-start-with-sources.md)
|
||||
- [(FR) - Créer son propre layer](./fr/tutorials/create-custom-layer.md)
|
@ -2,7 +2,7 @@
|
||||
|
||||
## Étapes
|
||||
|
||||
1. Sur le serveur hébergeant les services Bouncer, utiliser le CLI pour créer un nouveau calque ("layer") pour votre proxy. Dans l'exemple, nous utiliserons le proxy `cadoles` créé dans le cadre du tutoriels ["Premiers pas"](../getting-started.md).
|
||||
1. Sur le serveur hébergeant les services Bouncer, utiliser le CLI pour créer un nouveau layer pour votre proxy. Dans l'exemple, nous utiliserons le proxy `cadoles` créé dans le cadre du tutoriels ["Premiers pas"](../getting-started.md).
|
||||
|
||||
```bash
|
||||
# Création d'un calque nommé 'my-queue' pour le proxy 'cadoles' de type 'queue'
|
||||
@ -19,7 +19,7 @@
|
||||
+----------+-------+---------+--------+---------+-------------------------+-------------------------+
|
||||
```
|
||||
|
||||
2. À ce stade, le calque est encore inactif. Définir la capacité de la file d'attente à 1 et activer le calque en utilisant le CLI
|
||||
2. À ce stade, le layer est encore inactif. Définir la capacité de la file d'attente à 1 et activer le layer en utilisant le CLI:
|
||||
|
||||
```bash
|
||||
bouncer admin layer update --proxy-name cadoles --layer-name my-queue --layer-enabled=true --layer-options '{"capacity": 1}'
|
||||
|
@ -1,64 +1,11 @@
|
||||
# Créer son propre layer
|
||||
|
||||
Dans ce tutoriel, nous allons voir comme implémenter un layer personnalisé qui permettra d'ajouter une authentification de type [`Basic Auth](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) à un proxy.
|
||||
Dans ce tutoriel, nous verrons comment implémenter un layer personnalisé qui permettra d'ajouter une authentification de type [`Basic Auth](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) à un proxy.
|
||||
|
||||
## Prérequis
|
||||
|
||||
Les éléments suivants doivent être installés sur votre machine:
|
||||
|
||||
- [Golang > 1.20](https://go.dev/)
|
||||
- [Docker](https://www.docker.com/)
|
||||
- [Git](https://git-scm.com/)
|
||||
- [GNU Make](https://www.gnu.org/software/make/)
|
||||
|
||||
Avoir un environnement de développement local fonctionnel. Voir tutoriel ["Démarrer avec les sources"](./getting-started-with-sources.md).
|
||||
## Étapes
|
||||
|
||||
### Préparer son environnement de développement
|
||||
|
||||
1. Cloner le dépôt des sources du projet Bouncer
|
||||
|
||||
```
|
||||
git clone https://forge.cadoles.com/Cadoles/bouncer
|
||||
```
|
||||
|
||||
2. Se positionner dans le répertoire du projet
|
||||
|
||||
```
|
||||
cd bouncer
|
||||
```
|
||||
|
||||
3. Lancer le projet en mode "développement"
|
||||
|
||||
```
|
||||
make watch
|
||||
```
|
||||
|
||||
Si toutes les dépendances sont correctement installées et configurées sur votre machine, la console devrait afficher une série de messages pour ensuite s'arrêter sur quelque chose ressemblant à:
|
||||
|
||||
```
|
||||
14:47:06: daemon: make run BOUNCER_CMD="--config config.yml server admin run"
|
||||
2023-06-23 20:47:06.095 [INFO] <./internal/command/server/admin/run.go:42> RunCommand.func1 listening {"url": "http://127.0.0.1:8081"}
|
||||
2023-06-23 20:47:06.095 [INFO] <./internal/admin/server.go:126> (*Server).run http server listening
|
||||
14:47:06: daemon: make run-redis
|
||||
bouncer-redis
|
||||
docker run --rm -t \
|
||||
--name bouncer-redis \
|
||||
-v /home/wpetit/workspace/bouncer/data/redis:/data \
|
||||
-p 6379:6379 \
|
||||
redis:alpine3.17 \
|
||||
redis-server --save 60 1 --loglevel warning
|
||||
1:C 23 Jun 2023 20:47:06.754 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
||||
1:C 23 Jun 2023 20:47:06.754 # Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
|
||||
1:C 23 Jun 2023 20:47:06.754 # Configuration loaded
|
||||
1:M 23 Jun 2023 20:47:06.759 # Warning: Could not create server TCP listening socket ::*:6379: unable to bind socket, errno: 97
|
||||
1:M 23 Jun 2023 20:47:06.760 # Server initialized
|
||||
1:M 23 Jun 2023 20:47:06.760 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect
|
||||
```
|
||||
|
||||
À ce stade, le serveur `bouncer-admin` écoute sur http://127.0.0.1:8081 et le serveur `bouncer-proxy` sur http://127.0.0.1:8080.
|
||||
|
||||
L'outil [`modd`](https://github.com/cortesi/modd) est utilisé pour surveiller les modifications sur les sources et relancer automatiquement la compilation et les services en cas de changement.
|
||||
|
||||
### Préparer la structure de base du nouveau layer
|
||||
|
||||
Une implémetation d'un layer se compose majoritairement de 3 éléments:
|
||||
|
125
doc/fr/tutorials/getting-started-with-sources.md
Normal file
125
doc/fr/tutorials/getting-started-with-sources.md
Normal file
@ -0,0 +1,125 @@
|
||||
# Démarrer avec les sources
|
||||
|
||||
Dans ce tutoriel, nous verrons comment lancer un environnement de développement en local sur notre machine afin de travailler sur les sources de Bouncer.
|
||||
|
||||
## Prérequis
|
||||
|
||||
Les éléments suivants doivent être installés sur votre machine:
|
||||
|
||||
- [Golang > 1.20](https://go.dev/)
|
||||
- [Docker](https://www.docker.com/)
|
||||
- [Git](https://git-scm.com/)
|
||||
- [GNU Make](https://www.gnu.org/software/make/)
|
||||
|
||||
Les ports suivants doivent être disponibles sur votre machine:
|
||||
|
||||
- `8080`
|
||||
- `8081`
|
||||
|
||||
## Étapes
|
||||
|
||||
1. Cloner le dépôt des sources du projet Bouncer
|
||||
|
||||
```
|
||||
git clone https://forge.cadoles.com/Cadoles/bouncer
|
||||
```
|
||||
|
||||
2. Se positionner dans le répertoire du projet
|
||||
|
||||
```
|
||||
cd bouncer
|
||||
```
|
||||
|
||||
3. Lancer le projet en mode "développement"
|
||||
|
||||
```
|
||||
make watch
|
||||
```
|
||||
|
||||
Si toutes les dépendances sont correctement installées et configurées sur votre machine, la console devrait afficher une série de messages pour ensuite s'arrêter sur quelque chose ressemblant à:
|
||||
|
||||
```
|
||||
14:47:06: daemon: make run BOUNCER_CMD="--config config.yml server admin run"
|
||||
2023-06-23 20:47:06.095 [INFO] <./internal/command/server/admin/run.go:42> RunCommand.func1 listening {"url": "http://127.0.0.1:8081"}
|
||||
2023-06-23 20:47:06.095 [INFO] <./internal/admin/server.go:126> (*Server).run http server listening
|
||||
14:47:06: daemon: make run-redis
|
||||
bouncer-redis
|
||||
docker run --rm -t \
|
||||
--name bouncer-redis \
|
||||
-v /home/wpetit/workspace/bouncer/data/redis:/data \
|
||||
-p 6379:6379 \
|
||||
redis:alpine3.17 \
|
||||
redis-server --save 60 1 --loglevel warning
|
||||
1:C 23 Jun 2023 20:47:06.754 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
||||
1:C 23 Jun 2023 20:47:06.754 # Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
|
||||
1:C 23 Jun 2023 20:47:06.754 # Configuration loaded
|
||||
1:M 23 Jun 2023 20:47:06.759 # Warning: Could not create server TCP listening socket ::*:6379: unable to bind socket, errno: 97
|
||||
1:M 23 Jun 2023 20:47:06.760 # Server initialized
|
||||
1:M 23 Jun 2023 20:47:06.760 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect
|
||||
```
|
||||
|
||||
À ce stade, le serveur `bouncer-admin` écoute sur http://127.0.0.1:8081 et le serveur `bouncer-proxy` sur http://127.0.0.1:8080.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> L'outil [`modd`](https://github.com/cortesi/modd) est utilisé pour surveiller les modifications sur les sources et relancer automatiquement la compilation et les services en cas de changement.
|
||||
|
||||
## Commandes `make` utiles
|
||||
|
||||
### `make watch`
|
||||
|
||||
Surveiller les sources, compiler celles ci en cas de modifications et lancer les services `bouncer-proxy` et `bouncer-admin`.
|
||||
|
||||
#### `make test`
|
||||
|
||||
Exécuter les tests unitaires/d'intégration du projet.
|
||||
|
||||
#### `make build`
|
||||
|
||||
Compiler une version de développement du binaire `bouncer`.
|
||||
|
||||
#### `make docker-build`
|
||||
|
||||
Construire une image Docker pour Bouncer.
|
||||
|
||||
Vous pouvez ensuite lancer l'image localement avec la commande:
|
||||
|
||||
```
|
||||
docker run \
|
||||
-it --rm \
|
||||
reg.cadoles.com/cadoles/bouncer:<tag> \
|
||||
-p 8080:8080 \
|
||||
bouncer server proxy run
|
||||
```
|
||||
|
||||
## Arborescence du projet
|
||||
|
||||
```bash
|
||||
.
|
||||
├── bin # Répertoire de destination des binaires Go de développement
|
||||
├── cmd # Package principal (main) du binaire Bouncer
|
||||
├── data # Répertoire des données de développement (Redis)
|
||||
├── dist # Répertoire de destination des archives/paquets pour la publication
|
||||
├── doc # Répertoire de documentation du projet
|
||||
├── internal # Source Go du projet
|
||||
│ ├── admin
|
||||
│ ├── auth
|
||||
│ ├── chi
|
||||
│ ├── client
|
||||
│ ├── command
|
||||
│ ├── config
|
||||
│ ├── format
|
||||
│ ├── imports
|
||||
│ ├── jwk
|
||||
│ ├── proxy
|
||||
│ ├── schema
|
||||
│ ├── setup
|
||||
│ └── store
|
||||
├── layers # Fichiers annexes liés aux layers (templates HTML)
|
||||
│ └── queue
|
||||
├── misc # Fichiers annexes
|
||||
│ ├── jenkins # Fichiers liés au pipeline d'intégration continue Jenkins
|
||||
│ ├── logo # Logo du projet
|
||||
│ └── packaging # Fichiers liés à l'empaquetage des binaires
|
||||
└── tools # Outils utilisés en développement
|
||||
```
|
@ -50,9 +50,10 @@ func Main(buildDate, projectVersion, gitRef, defaultConfigPath string, commands
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "workdir",
|
||||
Value: "",
|
||||
Usage: "The working directory",
|
||||
Name: "workdir",
|
||||
Value: "",
|
||||
EnvVars: []string{"BOUNCER_WORKDIR"},
|
||||
Usage: "The working directory",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "projectVersion",
|
||||
|
Loading…
x
Reference in New Issue
Block a user