Closed simonw closed 3 years ago
Here's the problem: https://github.com/simonw/datasette-publish-fly/blob/be161ee1b7481407feeddd25f312191718b0fe8d/datasette_publish_fly/__init__.py#L108-L113
It looks like the design of flyctl apps create
changed at some point - it now creates the fly.toml
file for you, previously it didn't do that.
% flyctl apps create --help
The APPS CREATE command will both register a new application
with the Fly platform and create the fly.toml file which controls how
the application will be deployed. The --builder flag allows a cloud native
buildpack to be specified which will be used instead of a Dockerfile to
create the application image when it is deployed.
Usage:
flyctl apps create [APPNAME] [flags]
Flags:
--builder string The Cloud Native Buildpacks builder to use when deploying the app
-h, --help help for create
--name string The app name to use
--org string The organization that will own the app
-p, --port string Internal port on application to connect to external services
Global Flags:
-t, --access-token string Fly API Access Token
-j, --json json output
-v, --verbose verbose output
Urgh. I don't want it to create a fly.toml
file.
It looks like this sequence avoids the interactive prompts:
% flyctl apps create --name fly-no-fly-toml2 --builder 'Docker' --port 8080
Selected App Name: fly-no-fly-toml2
Automatically selected personal organization: Simon Willison
New app created
Name = fly-no-fly-toml2
Organization = personal
Version = 0
Status =
Hostname = <empty>
App will initially deploy to sjc (Sunnyvale, California (US)) region
Wrote config file fly.toml
(datasette-publish-fly) datasette-publish-fly % cat fly.toml
# fly.toml file generated for fly-no-fly-toml2 on 2020-12-12T11:21:57-08:00
app = "fly-no-fly-toml2"
[build]
builder = "Docker"
[[services]]
internal_port = 8080
protocol = "tcp"
[services.concurrency]
hard_limit = 25
soft_limit = 20
[[services.ports]]
handlers = ["http"]
port = "80"
[[services.ports]]
handlers = ["tls", "http"]
port = "443"
[[services.tcp_checks]]
interval = 10000
timeout = 2000
I'm going to run fly apps create
against a temporary directory so that the fly.toml
file doesn't get written to the current directory the user is in when they run datasette publish fly
.
Tried that, now I'm getting a new error in the Fly logs:
[2020-12-12T19:31:57+00:00] printenv
[2020-12-12T19:31:57+00:00] [1mDeploying datasette-publish-fly-december-2020[0m
[2020-12-12T19:31:57+00:00] [32m==> Validating App Configuration[0m
[2020-12-12T19:32:00+00:00] [31mError[0m App configuration is not valid
Here's what fly.toml
looks like:
app = "datasette-publish-fly-december-2020"
[[services]]
internal_port = 8080
protocol = "tcp"
[services.concurrency]
hard_limit = 25
soft_limit = 20
[[services.ports]]
handlers = ["http"]
port = "80"
[[services.ports]]
handlers = ["tls", "http"]
port = "443"
[[services.tcp_checks]]
interval = 10000
timeout = 2000
That looks OK to me - it's similar to the example here https://community.fly.io/t/not-possible-to-validate-configuration-server-returned-500/172
Maybe they changed flyctl deploy
too?
% flyctl deploy --help
Deploy an application to the Fly platform. The application can be a local
image, remote image, defined in a Dockerfile or use a CNB Buildpack.
Use the --config/-c flag to select a specific toml configuration file.
Use the --image/-i flag to specify a local or remote image to deploy.
Use the --detach flag to return immediately from starting the deployment rather
than monitoring the deployment progress.
Use flyctl monitor to restart monitoring deployment progress
Usage:
flyctl deploy [<workingdirectory>] [flags]
Flags:
-a, --app string App name to operate on
--build-arg strings Set of build time variables in the form of NAME=VALUE pairs. Can be specified multiple times.
-c, --config string Path to an app config file or directory containing one (default "./fly.toml")
--detach Return immediately instead of monitoring deployment progress
--dockerfile string Path to a Dockerfile. Defaults to the Dockerfile in the working directory.
-h, --help help for deploy
-i, --image string Image tag or id to deploy
--image-label string Image label to use when tagging and pushing to the fly registry. Defaults to "deployment-{timestamp}".
--local-only Only perform builds locally using the local docker daemon
--remote-only Perform builds remotely without using the local docker daemon
--strategy string The strategy for replacing running instances. Options are canary, rolling, or immediate. Default is canary
Global Flags:
-t, --access-token string Fly API Access Token
-j, --json json output
-v, --verbose verbose output
I'm going to try using the --config
and --app
arguments.
Maybe I need to add .
- I found this example in the Fly app dashboard:
flyctl --app datasette-publish-fly-december-2020 deploy .
OK that's an interesting error:
[2020-12-12T19:52:25+00:00] return fn(conn)
[2020-12-12T19:52:25+00:00] File "/usr/local/lib/python3.8/site-packages/datasette/database.py", line 145, in sql_operation_in_thread
[2020-12-12T19:52:25+00:00] cursor.execute(sql, params if params is not None else {})
[2020-12-12T19:52:25+00:00] sqlite3.DatabaseError: malformed database schema (generated_columns) - near "AS": syntax error
Looks like the version of Datasette that gets deployed doesn't support generated columns yet! I should treat that as a separate, core Datasette bug.
OK, got it working again.