-
Notifications
You must be signed in to change notification settings - Fork 235
/
django.go
69 lines (60 loc) · 1.69 KB
/
django.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package scanner
import (
"github.com/superfly/flyctl/helpers"
"github.com/superfly/flyctl/internal/app"
)
// setup django with a postgres database
func configureDjango(sourceDir string, config *ScannerConfig) (*SourceInfo, error) {
if !checksPass(sourceDir, dirContains("requirements.txt", "(?i)Django")) {
return nil, nil
}
s := &SourceInfo{
Family: "Django",
Port: 8000,
Files: templates("templates/django"),
Env: map[string]string{
"PORT": "8000",
},
Secrets: []Secret{
{
Key: "SECRET_KEY",
Help: "Django needs a random, secret key. Use the random default we've generated, or generate your own.",
Generate: func() (string, error) {
return helpers.RandString(64)
},
},
},
Statics: []app.Static{
{
GuestPath: "/app/public",
UrlPrefix: "/static/",
},
},
SkipDeploy: true,
}
// check if requirements.txt has a postgres dependency
if checksPass(sourceDir, dirContains("requirements.txt", "psycopg2")) {
s.InitCommands = []InitCommand{
{
// python makemigrations
Command: "python",
Args: []string{"manage.py", "makemigrations"},
Description: "Creating database migrations",
},
}
s.ReleaseCmd = "python manage.py migrate"
if !checksPass(sourceDir, dirContains("requirements.txt", "database_url")) {
s.DeployDocs = `
Your Django app is almost ready to deploy!
We recommend using the database_url(pip install dj-database-url) to parse the DATABASE_URL from os.environ['DATABASE_URL']
For detailed documentation, see https://fly.dev/docs/django/
`
} else {
s.DeployDocs = `
Your Django app is ready to deploy!
For detailed documentation, see https://fly.dev/docs/django/
`
}
}
return s, nil
}