Hello there,
I am very happy with now. However, infinite URLs is making me feel not-so-good.
Is there a way I could reuse a URL?
I am using meteor-now to deploy my apps with mongodb living on google cloud and custom domain. I want my now to help provide me an option to reuse a URL for deployment.
All deployments are immutable and receive a unique url which then can be aliased to a nicer domain name or any subdomain of now.sh
Please checkout: https://zeit.co/docs/features/aliases
@jamo Thank you. I use alias but each time I make change I have an alias rm <id> and alias add <url.sh> <my.url>.
Is this the expected behaviour?
you can just now alias my-new-random-like-url.now.sh my-site.now.sh without removing the existing one.
You can also add this to your package.json to enable semi-automatic aliasing via now alias:
{
"now": {
"alias": "yoururl"
}
}
However you'll still have to manually remove your old deployments. 🙁
I feel this could be more automated with:
$ now --replace
# same as
# $ now
# $ now alias
# $ now remove <previous>
There's no reason/need to remove any existing deployments or aliases. Our system was built on that premise.
If there's no reason/need, why does now remove exist?
@leo I agree with @bfred-it, now loses its magic as soon as you want to redeploy an app but can’t do it to the same instance, especially when you have it set up to not freeze. Considering now bills by how many instances we can have active, I think it’s critical to make it easy to redeploy to an instance or replace it
@Lepozepo if you have scaled a deployment and it has an alias when you move that alias to another deployment is going to move the scale config to the new aliased deployment and the old one is going to go back to min 0 max 1 so you don't need to care about old deployments because they're going to sleep eventually.
Personally I've never removed a deployment, I just let them freeze, also I don't think it make that much sense to deploy to the same instance because 2 reasons:
my-app-abc123.now.sh to your users, you want a custom domain (or a better .now.sh subdomain) and for that we have aliases.Also unique urls per deployment enable auto staging deployments by default because that url works as a staging environment you can upgrade to production with just now alias.
This issue is not about reusing instances (which never happens), but removing old deployments _after_ a deploy+alias, automatically.
@sergiodxa awesome, I didn't know it would automatically set the old deployment to min 0
@bfred-it - I was just discussing this in Slack and stumbled across this - couldn't agree more would be nice to have something built in.
I've just started doing now rm name --yes; now deploy - which ain't great.
You can do this:
now && now alias && now remove my-package-name --safe
@jaydenseric doesn't work. my-package-name has to be the previous unaliased deployment name, which means the command you supplied varies every time.
@bfred-it No; it can be the package name in package.json, which persists.
Fair, that works! (Unless you have multiple independent apps under the same "app name", in which case it's kinda dangerous)
adding
"now":{
"alias":"aliasname"
}
to my package.json was not visible to the default now alias command
I had to create now.json and place the alias name in there, then the command:
now && now alias && now remove my-package-name --safe
works
I do agree that it would be nice if this was a bit more simple.
The
now --alias
command does not seem to work anymore either?
Seriously, this answer should be part of the official docs!! @jaydenseric
> You can do this:
now && now alias && now remove my-package-name --safe
So to summarise:
"name": "my-package-name"
"alias": "mydomain.com",
"name": "my-package-name"
now && now alias && now my-package-name --safe@satyavh Setting the now.json works well, thanks!
{
"alias": "my-package-name",
"name": "my-package-name"
}
I was finally able to automate the remove step with the following:
now --public --token abc123 \
&& now --token abc123 alias \
&& now --token abc123 remove my-package-name --safe -y
Now the CI can deploy every build and the URL remains the same!
@styfle you can use -y or --yes to remove the echo
@sergiodxa I don't see that in the docs that @jamo linked to above.
You can see it on now --help
@sergiodxa I still don't see it.
$ now --help
Δ now [options] <command | path>
Commands:
Cloud
deploy [path] Performs a deployment (default)
ls | list [app] List deployments
rm | remove [id] Remove a deployment
ln | alias [id] [url] Configures aliases for deployments
domains [name] Manages your domain names
certs [cmd] Manages your SSL certificates
secrets [name] Manages your secret environment variables
dns [name] Manages your DNS records
logs [url] Displays the logs for a deployment
scale [args] Scales the instance count of a deployment
help [cmd] Displays complete help for [cmd]
Administrative
billing | cc [cmd] Manages your credit cards and billing methods
upgrade | downgrade [plan] Upgrades or downgrades your plan
teams [team] Manages your teams
switch Switches between teams and your account
login Login into your account or creates a new one
logout Logout from your account
Options:
-h, --help Output usage information
-v, --version Output the version number
-n, --name Set the name of the deployment
-A FILE, --local-config=FILE Path to the local `now.json` file
-Q DIR, --global-config=DIR Path to the global `.now` directory
-d, --debug Debug mode [off]
-f, --force Force a new deployment even if nothing has changed
-t TOKEN, --token=TOKEN Login token
-l, --links Copy symlinks without resolving their target
-p, --public Deployment is public (`/_src` is exposed) [on for oss, off for premium]
-e, --env Include an env var (e.g.: `-e KEY=value`). Can appear many times.
-E FILE, --dotenv=FILE Include env vars from .env file. Defaults to '.env'
-C, --no-clipboard Do not attempt to copy URL to clipboard
-N, --forward-npm Forward login information to install private npm modules
--session-affinity Session affinity, `ip` or `random` (default) to control session affinity
-T, --team Set a custom team scope
Enforceable Types (by default, it's detected automatically):
--npm Node.js application
--docker Docker container
--static Static file hosting
Examples:
– Deploy the current directory
$ now
– Deploy a custom path
$ now /usr/src/project
– Deploy a GitHub repository
$ now user/repo#ref
– Deploy with environment variables
$ now -e NODE_ENV=production -e SECRET=@mysql-secret
– Show the usage information for the sub command `list`
$ now help list
@styfle it's on now rm --help – sorry for the confusion.
@matheuss Thanks, that worked. I updated my comment above above for others to use.
And now that I look in the FAQ, it's already there under "How do I remove an old deployment?"
This really should be part of the docs. Although they cover aliasing, they don't explain how to handle ongoing deploys using the same alias.
I second @Undistraction.. @satyavh comment should be in the docs!
I'm using this as my default template by now:
package.json excerpt:
{
"scripts": {
"deploy": "now --public && now alias && now rm $npm_package_now_name --safe --yes"
},
"now": {
"name": "my-cool-project",
"alias": [
"my-cool-project.now.sh",
"production.my-domain.com"
]
}
}
Works well with yarn:
yarn deploy
Most helpful comment
I feel this could be more automated with: