Deploying on Zerops
Run Gleam with Ease. Zero Ops required.
Run Gleam with Ease. Zero Ops required.
Zerops is a dev-first cloud platform and easy to use and economically viable deployment platform with free $15 credits no credit card required. You can get $50 more after adding $10 into your zerops account.
Zerops’ free allowance of $15 is enough to deploy any type of full stack project without any credit card.
We will need a Gleam backend web application to deploy in this guide, so first we will make one. If you already have an application skip to the next section.
Create a new Gleam project and add the required dependencies.
gleam new my_web_app
cd my_web_app
gleam add mist gleam_http gleam_erlang
Open up src/my_web_app.gleam
and replace the contents with this code that
defines a micro web application.
import mist
import gleam/erlang/process
import gleam/bytes_builder
import gleam/http/response.{Response}
pub fn main() {
let assert Ok(_) =
web_service
|> mist.new
|> mist.bind("0.0.0.0")
|> mist.port(8080)
|> mist.start_http
process.sleep_forever()
}
fn web_service(_request) {
let body = bytes_builder.from_string("Hello, Zerops!")
Response(200, [], mist.Bytes(body))
}
Now we have a web application that listens on port 8080 and can be started with
gleam run
.
Want to test Gleam with Postgres on Zerops without installing or setting up anything? Use the Zerops Gleam recipe Zerops x Gleam using the project import yaml mentioned below or Deploy with a Single Click.
project:
name: recipe-gleam
tags:
- zerops-recipe
services:
- hostname: api
type: gleam@1.5
enableSubdomainAccess: true
buildFromGit: https://github.com/zeropsio/recipe-gleam
- hostname: db
type: postgresql@16
mode: NON_HA
priority: 1
Projects and services can be added either through a Project add wizard or imported using a yaml structure:
# see https://docs.zerops.io/references/import for full reference
project:
name: recipe-gleam
services:
- hostname: app
type: gleam@1.5
This will create a project called recipe-gleam
with a Zerops Gleam service called app
.
zerops:
- setup: app
build:
base: gleam@1.5
buildCommands:
- gleam export erlang-shipment
deployFiles: build/erlang-shipment/~
run:
base: gleam@1.5
ports:
- port: 8080
httpSupport: true
start: ./entrypoint.sh run
Follow the instructions here to install zCli, the command-line interface for the Zerops.io platform.
irm https://zerops.io/zcli/install.ps1 | iex
curl -L https://zerops.io/zcli/install.sh | sh
npm i -g @zerops/zcli
Once installed use the CLI to connect to your Zerops Account:
Open Settings > Access Token Management in the Zerops app and generate a new access token.
Log in using your access token with the following command:
zcli login <token>
zcli push
This will deploy the package to Zerops service and after it successfully deploys you can enable public access through subdomain url with zcli service enable-subdomain
.
You can also setup git based deployments by connecting the app service with your GitHub / GitLab repository from inside the service detail.