Skip to Content
GuidesUsing persistent storage in Wasmer Edge Apps

Using persistent storage in Wasmer Edge Apps

In this tutorial, you will learn how to setup persistent storage for your edge apps

Let’s start with creating an edge application

You can quickstart with an application from one of our templates

wasmer app create --template static-website

Now, let’s edit app.yaml to setup persistent volume

Add

volumes: - name: data mount: /public/things_i_want_to_persist

to app.yaml. This will mount a persistent volume named data into /public/things_i_want_to_persist directory of your application

Now, let’s re-deploy the app

wasmer deploy

After deployment completes, you can open your app’s dashboard, printed in the deployment status: -> Dashboard: https://wasmer.io/apps/.... To see the persistent volume under the storage tab (e.g. https://wasmer.io/apps/{username}/{appname}/storage ). All the data that your application creates under the mounted directory will persist through app crashes, restarts and updates. The volumes are also s3 compatible. You can enable S3 access per volume and use any s3 client to retrieve and upload data

Accessing volume from outside of your app

app dashboard

via s3 clients

S3 access is opt-in per volume. First, enable it:

wasmer app volume enable-s3

Then retrieve the per-volume credentials (access key, secret key and endpoint):

wasmer app volume credentials

You can provide these credentials to any s3 client for accessing your volume.

By default the credentials are printed as an rclone configuration snippet for connecting to your volume; --format=rclone selects it explicitly, and json, yaml and table formats are also available

via wasmer.io

In the storage section of your app’s dashboard, you can see your volumes.

Clicking “Explore files” on a volume opens a file explorer to browse its files

You can also manage files remotely over SFTP

Proving persistency

Now, let’s upload “hello world” file to the volume. Enable S3 access, add the rclone configuration printed by wasmer app volume credentials to your rclone config, and upload

echo "Hello World!" > index.html rclone copy ./index.html edge-volume:/data

(/data is the name of the volume, since you can mount multiple volumes to your app, you access to your data under via rclone in /{volume_name}) The template app we used will show the file you uploaded at https://your_app_url.wasmer.app/things_i_want_to_persist/index.html  You can also view your uploaded file with your s3 client or the dashboard file explorer

Now, let’s force a container restart. When updating your app with wasmer deploy, a new instance of your app will be created. So a new filesystem will be in use for your app and the volumes will be mounted After running wasmer deploy, you can see your index.html is still there. View from the app at url https://your_app_url.wasmer.app/things_i_want_to_persist/index.html , from your s3 client, or from the dashboard file explorer

Last updated on