Install Wasmer
Wasmer allows you to run applications either Standalone (via the CLI) or Embedded within other languages such as C/C++, Rust, Python, Go, PHP, Ruby…
Unix (macOS, Linux):
curl https://get.wasmer.io -sSfL | shOr, to install a specific version:
curl https://get.wasmer.io -sSfL | sh -s "v4.3.0"Other installation methods are available here:
https://github.com/wasmerio/wasmer-install
(在windows系统下,可以在powershell中,安装该程序,命令为:
iwr https://win.wasmer.io -useb | iex )
Is Wasmer up to date?
Wasmer updates very frequently. If you have installed Wasmer some time ago, chances are your Wasmer version is out of date. Get the latest version of Wasmer by running:
wasmer self-updatefrom https://docs.wasmer.io/install/--------------
You have an application you want to deploy on Wasmer Edge? You’re in the right place!
Welcome to wasmer deploy. For most languages and frameworks, you can deploy your app from zero, with the following steps:
Install Wasmer
Click here for instructions on how to install Wasmer if you haven’t done it already!
Create an account
You can create an account directly via wasmer login or via the Wasmer website:
wasmer.io/signup
Run wasmer deploy
The wasmer deploy command will make sure that everything is in place for you to deploy your
app: it will guide you through the creation of the app and its deployment if it doesn’t exist,
or redeploy it after it changes.
The deploy command is a one-stop-shop for multiple functionalities needed to
deploy apps on Wasmer Edge. To learn more about the commands available in the
CLI to manage your Wasmer Edge apps, refer to the dedicated CLI
page!
from https://docs.wasmer.io/edge/get-started/
-----
Deploy Git repositories on Wasmer Edge
Wasmer Edge can deploy an app from a connected Git repository. This lets you keep your source code and deployment configuration in Git while Wasmer handles the deployment.
Git deployments currently focus on GitHub repositories. If you use another Git
provider, you can still deploy from a local checkout with
wasmer deploy.
How Git deployments work
- Connect a repository to a Wasmer Edge app.
- Choose the branch that should deploy to production, usually
main. - Push changes to that branch when you want to update the app.
App configuration
If an app.yaml file is present in the repository, Wasmer extends the app’s
configuration with the values from that file during deployment.
Production branch
The production branch is the branch Wasmer treats as the source of the live app.
Most projects use main, but you can choose the branch that matches your release
process.
Deploy without Git
You can always deploy from a local checkout:
wasmer deployThis is useful when you are setting up a project for the first time, testing a deployment locally, or using a Git provider that is not connected to Wasmer Edge.
from https://docs.wasmer.io/edge/git/
-----
Deploy GitHub repositories with Wasmer
Wasmer for GitHub connects a GitHub repository to Wasmer Edge so changes can be deployed from GitHub.
Before you start
- A Wasmer account
- Access to the GitHub repository you want to deploy
- A Wasmer Edge app, or permission to create one
Connect a repository
Open your Wasmer Edge app
Go to the Wasmer dashboard and select the app you want to connect to GitHub.
Connect GitHub
Open the app’s Git settings and choose GitHub as the repository provider. If prompted, authorize Wasmer to access the repository or organization.
Select the repository and branch
Choose the repository that contains your app and select the branch Wasmer should
deploy to production. Most apps use main.
Deploy
Save the connection and deploy the app. Future changes pushed to the selected branch can be deployed through the Git connection.
App configuration
If an app.yaml file is present in the repository, Wasmer extends the app’s
configuration with the values from that file during deployment.
Pull requests
Use pull requests to review changes before merging them into the production
branch. If your app needs a one-off deployment while a change is still in review,
you can deploy that branch from a local checkout with wasmer deploy.
Troubleshooting
I do not see my repository
Make sure the GitHub account or organization connected to Wasmer has access to the repository. For organization repositories, an organization owner may need to approve access.
A deployment did not start
Check that the repository is connected to the right app and that the pushed branch is the branch configured for deployment. You can still deploy manually from the repository checkout:
wasmer deployfrom https://docs.wasmer.io/edge/git/wasmer-for-github/----- Quickstart guide for a static website
In this quickstart guide, you’ll learn the process of deploying a static site on Wasmer Edge. We will cover installation of the CLI, setting up a new static site, and deploying it.
If you want to deploy a static site made from frameworks like React, Vue, or Svelte, you can follow our React Static Site tutorial.
Deploying a static site
Install Wasmer
Click here for instructions on how to install Wasmer if you haven’t done it already!
Log in into Wasmer
Create a new account in Wasmer . Then, log in into the Wasmer CLI and follow the provided steps to provide the CLI access to your Wasmer account.
wasmer loginDeploy!
We begin creating a new empty directory.
mkdir my-new-site
cd my-new-siteThen, running a single command, we can setup a static website.
wasmer deploy --template=static-website Expect to see output similar to this:
It seems you are trying to create a new app!
✔ Who should own this app? · wasmer-user
✔ What should be the name of the app? · my-new-site
✔ Unpacked template
✔ Do you want to deploy the app now? · yes
Loading local package (manifest path: ~/wasmer-user/Projects/my-new-site/.)
✔ Correctly built package locally
✔ Package correctly uploaded
✔ Succesfully pushed release to namespace wasmer-user on the registry
Deploying app my-new-site (wasmer-user) to Wasmer Edge...
App my-new-site (wasmer-user) was successfully deployed 🚀
https://my-new-site-wasmer-user.wasmer.app
→ Unique URL: https://2dyh6i3cvx1y.id.wasmer.app
→ Dashboard: https://wasmer.io/apps/wasmer-user/my-new-site
Waiting for new deployment to become available...
(You can safely stop waiting now with CTRL-C)The above command will do the following:
- Download the template from the registry
- Store the template locally in your current directory (try running
ls -la) - Deploy it to Wasmer Edge
Don’t change the public directory attribute in the wasmer.toml file for this tutorial.
If you want to learn how to specify a different directory for build output, check out our React Static Site tutorial.
Try clicking the URL which is under the deployment message https://my-new-site-wasmer-user.wasmer.app, and expect to see something like:
The deployment URL follows the format https://<app-name>-<app-owner>.wasmer.app
To illustrate the lifecycle of an app, let’s edit the index.html file in the public folder:
Your directory structure should look like this:
Lets modify index.html:
sed -i -e 's/Hi from the Edge/This is our new title!/g' public/index.html Now, let’s redeploy it:
wasmer deployWhen refreshing the browser, expect the page to have been updated:
Currently, the public directory only contains a basic index.html file.
You can now modify this directory and copy your own files (HTML, CSS, JavaScript, images, etc) as needed.
Test your site locally
You can also test your site locally before deploying the app on Wasmer Edge by running the following command:
wasmer run .This will start a local server using the Static Web Server on http://localhost:8080.
You can also specify a different port by passing the --port flag, as in wasmer run . -- --port=<your-port>.
The arguments after -- (double dash) are passed to the underlying server running in the Wasmer runtime.
You can see all the available options with wasmer run --help or click here to see the full documentation.
To see all the avilable options for the static web server, run wasmer run . -- --help.
Conclusion
Congratulations! You have successfully deployed a static site on Wasmer Edge 🚀.
Tip: To make changes to your site, simply modify the files in the public directory and run
wasmer deployagain to deploy the changes.
from https://docs.wasmer.io/edge/guides/static-site/
-----
https://github.com/wasmer-examples/static-website
No comments:
Post a Comment