Re-arrange docker-compose files
This commit is contained in:
parent
2254c30366
commit
2a4b2aaa31
14 changed files with 523 additions and 20 deletions
23
Makefile
23
Makefile
|
@ -1,14 +1,21 @@
|
|||
PHONY: all
|
||||
|
||||
dockerized:
|
||||
docker-compose -f compose/docker-compose.yml down
|
||||
docker-compose -f compose/docker-compose.yml up --build -d
|
||||
prod:
|
||||
docker-compose -f docker/oef_prod/docker-compose.yml down
|
||||
docker-compose -f docker/oef_prod/docker-compose.yml up --build -d
|
||||
|
||||
dev:
|
||||
killall main || echo "Process was not running."
|
||||
docker-compose -f compose/docker-compose_outside_docker.yml down
|
||||
docker-compose -f compose/docker-compose_outside_docker.yml up -d db
|
||||
docker-compose -f compose/docker-compose_outside_docker.yml up -d smtp
|
||||
go run -race main.go --config=config/config_dev.yaml &
|
||||
docker-compose -f docker/oef_dev/docker-compose.yaml down
|
||||
docker-compose -f docker/oef_dev/docker-compose.yaml up -d db
|
||||
docker-compose -f docker/oef_dev/docker-compose.yaml up -d smtp
|
||||
go run -race main.go --config=docker/oef_dev/config/config.yaml &
|
||||
|
||||
all: dockerized
|
||||
test:
|
||||
killall main || echo "Process was not running."
|
||||
docker-compose -f docker/oef_test/docker-compose.yaml down
|
||||
docker-compose -f docker/oef_test/docker-compose.yaml up -d db
|
||||
docker-compose -f docker/oef_test/docker-compose.yaml up -d smtp
|
||||
go run -race main.go --config=docker/oef_test/config/config.yaml &
|
||||
|
||||
all: prod
|
||||
|
|
|
@ -16,24 +16,30 @@ import (
|
|||
"github.com/gocarina/gocsv"
|
||||
)
|
||||
|
||||
type genFunc func(string) error
|
||||
type config struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
type genFunc func(string, *config) error
|
||||
|
||||
var (
|
||||
generators map[string]genFunc
|
||||
templateDir string = "./templates"
|
||||
url string = "https://test.olimpiadi-economiaefinanza.it"
|
||||
)
|
||||
|
||||
func incr(value int) int {
|
||||
return value + 1
|
||||
}
|
||||
|
||||
func genResponseTargets(targetName string) error {
|
||||
func genResponseTargets(targetName string, conf *config) error {
|
||||
var data struct {
|
||||
Participants []*orm.Participant
|
||||
Tokens map[string]string
|
||||
Config *config
|
||||
}
|
||||
|
||||
data.Config = conf
|
||||
|
||||
log.Println("Read participants.csv...")
|
||||
|
||||
input, err := ioutil.ReadFile("./testdata/participants.csv")
|
||||
|
@ -47,7 +53,7 @@ func genResponseTargets(targetName string) error {
|
|||
log.Println("Obtaining tokens for each participants...")
|
||||
data.Tokens = make(map[string]string, 0)
|
||||
for _, participant := range data.Participants {
|
||||
token, err := client.GetToken(url, participant.FiscalCode, participant.Password)
|
||||
token, err := client.GetToken(data.Config.Url, participant.FiscalCode, participant.Password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -89,7 +95,8 @@ func init() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
target := flag.String("target", "responses", "Generate targets for various API endpoints.")
|
||||
target := flag.String("target", "responses", "Generate targets for participants responses.")
|
||||
url := flag.String("url", "http://localhost:3000", "The URL of the host.")
|
||||
flag.Parse()
|
||||
|
||||
fn, ok := generators[*target]
|
||||
|
@ -97,7 +104,7 @@ func main() {
|
|||
log.Fatal(errors.New("Unknown target"))
|
||||
}
|
||||
|
||||
err := fn(*target)
|
||||
err := fn(*target, &config{Url: *url})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{range $id, $participant := .Participants -}}
|
||||
{{- $username := $participant.FiscalCode -}}
|
||||
GET https://test.olimpiadi-economiaefinanza.it/responses/{{$id|incr}}/update?format=html&tpl_content=responses_add_update&tpl_layout=base&update=true&login_session={{index $.Tokens $username}}
|
||||
GET {{$.Config.Url}}/responses/{{$id|incr}}/update?format=html&tpl_content=responses_add_update&tpl_layout=base&update=true&login_session={{index $.Tokens $username}}
|
||||
{{end}}
|
||||
|
|
31
docker/oef_dev/config/config.yaml
Normal file
31
docker/oef_dev/config/config.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
url: "http://localhost:3000"
|
||||
log_level: 2
|
||||
language: "it"
|
||||
|
||||
keys:
|
||||
cookie_store_key: "something-very-secret"
|
||||
jwt_signing_key: "secret"
|
||||
|
||||
handlers:
|
||||
allow_session_url_query: true
|
||||
|
||||
orm:
|
||||
connection: "oef:oef@tcp(localhost:3307)/oef_dev"
|
||||
options: "charset=utf8&parseTime=True&loc=Local"
|
||||
automigrate: true
|
||||
regenerate: false
|
||||
|
||||
admin:
|
||||
username: "admin"
|
||||
password: "admin"
|
||||
|
||||
subscriber:
|
||||
password: "subscribe"
|
||||
|
||||
smtp:
|
||||
host: "localhost"
|
||||
port: 1025
|
||||
username: ""
|
||||
password: ""
|
||||
from: "no-reply@olimpiadi-economiaefinanza.it"
|
||||
bcc: "bcc@fake.org"
|
|
@ -3,7 +3,7 @@ version: "3.3"
|
|||
services:
|
||||
|
||||
app:
|
||||
build: ../
|
||||
build: ../../
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
|
@ -19,7 +19,6 @@ services:
|
|||
restart: always
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
# - ./sql:/docker-entrypoint-initdb.d
|
||||
env_file:
|
||||
- db.env
|
||||
ports:
|
17
docker/oef_prod/config/config.yaml
Normal file
17
docker/oef_prod/config/config.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
url: "http://localhost:3000"
|
||||
log_level: 2
|
||||
language: "it"
|
||||
|
||||
keys:
|
||||
cookie_store_key: "something-very-secret"
|
||||
jwt_signing_key: "secret"
|
||||
|
||||
orm:
|
||||
connection: "oef:oef@tcp(db:3306)/oef_dev"
|
||||
options: "charset=utf8&parseTime=True&loc=Local"
|
||||
automigrate: true
|
||||
regenerate: false
|
||||
|
||||
admin:
|
||||
username: "admin"
|
||||
password: "admin"
|
10
docker/oef_prod/db.env
Normal file
10
docker/oef_prod/db.env
Normal file
|
@ -0,0 +1,10 @@
|
|||
MYSQL_ROOT_PASSWORD=oef
|
||||
MYSQL_PASSWORD=oef
|
||||
MYSQL_DATABASE=oef_prod
|
||||
MYSQL_USER=oef
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ version: "3.3"
|
|||
services:
|
||||
|
||||
app:
|
||||
build: ../
|
||||
build: ../../
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
|
@ -11,7 +11,7 @@ services:
|
|||
- DB_PORT=3306
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ../config/config.yaml:/src/oef/config/config.yaml
|
||||
- ./config/config.yaml:/src/oef/config/config.yaml
|
||||
|
||||
db:
|
||||
image: mariadb
|
31
docker/oef_test/config/config.yaml
Normal file
31
docker/oef_test/config/config.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
url: "http://localhost:3000"
|
||||
log_level: 2
|
||||
language: "it"
|
||||
|
||||
keys:
|
||||
cookie_store_key: "something-very-secret"
|
||||
jwt_signing_key: "secret"
|
||||
|
||||
handlers:
|
||||
allow_session_url_query: true
|
||||
|
||||
orm:
|
||||
connection: "oef:oef@tcp(localhost:3307)/oef_test"
|
||||
options: "charset=utf8&parseTime=True&loc=Local"
|
||||
automigrate: true
|
||||
regenerate: false
|
||||
|
||||
admin:
|
||||
username: "admin"
|
||||
password: "admin"
|
||||
|
||||
subscriber:
|
||||
password: "subscribe"
|
||||
|
||||
smtp:
|
||||
host: "localhost"
|
||||
port: 1025
|
||||
username: ""
|
||||
password: ""
|
||||
from: "no-reply@olimpiadi-economiaefinanza.it"
|
||||
bcc: "bcc@fake.org"
|
10
docker/oef_test/db.env
Normal file
10
docker/oef_test/db.env
Normal file
|
@ -0,0 +1,10 @@
|
|||
MYSQL_ROOT_PASSWORD=oef
|
||||
MYSQL_PASSWORD=oef
|
||||
MYSQL_DATABASE=oef_test
|
||||
MYSQL_USER=oef
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
37
docker/oef_test/docker-compose.yaml
Normal file
37
docker/oef_test/docker-compose.yaml
Normal file
|
@ -0,0 +1,37 @@
|
|||
version: "3.3"
|
||||
|
||||
services:
|
||||
|
||||
app:
|
||||
build: ../../
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_PORT=3306
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ./config/config.yaml:/src/oef/config/config.yaml
|
||||
|
||||
db:
|
||||
image: mariadb
|
||||
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
|
||||
restart: always
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
- ./sql:/docker-entrypoint-initdb.d
|
||||
env_file:
|
||||
- db.env
|
||||
ports:
|
||||
- 3307:3306
|
||||
|
||||
smtp:
|
||||
image: digiplant/fake-smtp
|
||||
ports:
|
||||
- "1025:25"
|
||||
|
||||
volumes:
|
||||
db:
|
||||
|
||||
|
||||
|
355
docker/oef_test/sql/oef_test.sql
Normal file
355
docker/oef_test/sql/oef_test.sql
Normal file
File diff suppressed because one or more lines are too long
1
watch.sh
1
watch.sh
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
echo "Executing Makefile... $1"
|
||||
|
||||
make -k $1
|
||||
|
|
Loading…
Reference in a new issue