Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25f5fae505 | ||
|
|
1d4849acff | ||
|
|
58205c20a0 | ||
|
|
2a2f99dd76 |
@@ -10,6 +10,8 @@ _a web based password generator, with an API endpoint_
|
|||||||
* copy to clipboard
|
* copy to clipboard
|
||||||
* very small docker container, that only contains the application and has minimum attack surface
|
* very small docker container, that only contains the application and has minimum attack surface
|
||||||
* supports DarkMode and LightMode, you can toggle
|
* supports DarkMode and LightMode, you can toggle
|
||||||
|
* prepared to run behind a reverse-proxy, like traefik.
|
||||||
|
* logs in combined log format
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
|
|||||||
16
main.go
16
main.go
@@ -27,6 +27,21 @@ var (
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func initConfig() {
|
||||||
|
// 1. Counter-Pfad auslesen
|
||||||
|
if envFile := os.Getenv("COUNTER_FILE"); envFile != "" {
|
||||||
|
counterFile = envFile
|
||||||
|
log.Printf("counterFile st to %s, by ENV\n", envFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Debug-Modus auslesen (String zu Bool)
|
||||||
|
envDebug := strings.ToLower(os.Getenv("DEBUG"))
|
||||||
|
if envDebug == "true" || envDebug == "1" {
|
||||||
|
debug = true
|
||||||
|
log.Println("DEBUG-Modus ist aktiviert")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type responseWriter struct {
|
type responseWriter struct {
|
||||||
http.ResponseWriter
|
http.ResponseWriter
|
||||||
statusCode int
|
statusCode int
|
||||||
@@ -214,6 +229,7 @@ func helpHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
initConfig()
|
||||||
loadTemplates()
|
loadTemplates()
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
|
|||||||
@@ -25,21 +25,32 @@ for i in {1..10}; do echo $(curl -s https://passwd.scu.si/api/password); done
|
|||||||
you can build the app yourself like this:
|
you can build the app yourself like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
go build -o password-generator ./
|
go build ./
|
||||||
```
|
```
|
||||||
|
|
||||||
|
NOTE: If you build the app manually in go, like shown in this example, it will probably not run, since it misses a writeable `/data` directory.
|
||||||
|
You can set the counterFile by environment variable `COUNTER_FILE`, like this:
|
||||||
|
```
|
||||||
|
COUNTER_FILE=./counter.txt ./Web-Password
|
||||||
|
```
|
||||||
|
|
||||||
|
## debuging the app
|
||||||
|
|
||||||
|
You can turn on debug mode via environment variable `DEBUG`
|
||||||
|
```
|
||||||
|
DEBUG=true ./Web-Password
|
||||||
|
```
|
||||||
|
|
||||||
# build a docker container
|
# build a docker container
|
||||||
|
|
||||||
```
|
```
|
||||||
docker build -t password-generator .
|
docker build -t web-password:dev .
|
||||||
```
|
```
|
||||||
|
|
||||||
# start the docker container
|
# start the docker container
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run -p 8080:8080 password-generator
|
docker run -p 8080:8080 -v app_data:/data web-password:dev
|
||||||
```
|
```
|
||||||
|
|
||||||
## docker-compose
|
## docker-compose
|
||||||
|
|||||||
Reference in New Issue
Block a user