mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
Gleam provider (#313)
* Gleam provider * PHP snapshot needed an update too, apparently * Add docs * Fix nits
This commit is contained in:
+125
@@ -0,0 +1,125 @@
|
||||
{
|
||||
"deploy": {
|
||||
"base": {
|
||||
"image": "ghcr.io/railwayapp/railpack-runtime:latest"
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"include": [
|
||||
"/mise/shims",
|
||||
"/mise/installs",
|
||||
"/usr/local/bin/mise",
|
||||
"/etc/mise/config.toml",
|
||||
"/root/.local/state/mise",
|
||||
".tool-versions"
|
||||
],
|
||||
"step": "packages:mise:runtime"
|
||||
},
|
||||
{
|
||||
"include": [
|
||||
"build/erlang-shipment/."
|
||||
],
|
||||
"step": "build"
|
||||
}
|
||||
],
|
||||
"startCommand": "./build/erlang-shipment/entrypoint.sh run"
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"assets": {
|
||||
"mise.toml": "[mise.toml]"
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"path": "/mise/shims"
|
||||
},
|
||||
{
|
||||
"dest": ".tool-versions",
|
||||
"src": ".tool-versions"
|
||||
},
|
||||
{
|
||||
"customName": "create mise config",
|
||||
"name": "mise.toml",
|
||||
"path": "/etc/mise/config.toml"
|
||||
},
|
||||
{
|
||||
"cmd": "sh -c 'mise trust -a \u0026\u0026 mise install'",
|
||||
"customName": "install mise packages: erlang, gleam"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"image": "ghcr.io/railwayapp/railpack-builder:latest"
|
||||
}
|
||||
],
|
||||
"name": "packages:mise",
|
||||
"variables": {
|
||||
"MISE_CACHE_DIR": "/mise/cache",
|
||||
"MISE_CONFIG_DIR": "/mise",
|
||||
"MISE_DATA_DIR": "/mise",
|
||||
"MISE_INSTALLS_DIR": "/mise/installs",
|
||||
"MISE_NODE_VERIFY": "false",
|
||||
"MISE_SHIMS_DIR": "/mise/shims"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commands": [
|
||||
{
|
||||
"cmd": "gleam export erlang-shipment"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"step": "packages:mise"
|
||||
},
|
||||
{
|
||||
"include": [
|
||||
"."
|
||||
],
|
||||
"local": true
|
||||
}
|
||||
],
|
||||
"name": "build",
|
||||
"secrets": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"assets": {
|
||||
"mise.toml": "[mise.toml]"
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"path": "/mise/shims"
|
||||
},
|
||||
{
|
||||
"dest": ".tool-versions",
|
||||
"src": ".tool-versions"
|
||||
},
|
||||
{
|
||||
"customName": "create mise config",
|
||||
"name": "mise.toml",
|
||||
"path": "/etc/mise/config.toml"
|
||||
},
|
||||
{
|
||||
"cmd": "sh -c 'mise trust -a \u0026\u0026 mise install'",
|
||||
"customName": "install mise packages: erlang"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"image": "ghcr.io/railwayapp/railpack-builder:latest"
|
||||
}
|
||||
],
|
||||
"name": "packages:mise:runtime",
|
||||
"variables": {
|
||||
"MISE_CACHE_DIR": "/mise/cache",
|
||||
"MISE_CONFIG_DIR": "/mise",
|
||||
"MISE_DATA_DIR": "/mise",
|
||||
"MISE_INSTALLS_DIR": "/mise/installs",
|
||||
"MISE_NODE_VERIFY": "false",
|
||||
"MISE_SHIMS_DIR": "/mise/shims"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"deploy": {
|
||||
"base": {
|
||||
"image": "ghcr.io/railwayapp/railpack-runtime:latest"
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"include": [
|
||||
"/mise/shims",
|
||||
"/mise/installs",
|
||||
"/usr/local/bin/mise",
|
||||
"/etc/mise/config.toml",
|
||||
"/root/.local/state/mise"
|
||||
],
|
||||
"step": "packages:mise:runtime"
|
||||
},
|
||||
{
|
||||
"include": [
|
||||
"build/erlang-shipment/."
|
||||
],
|
||||
"step": "build"
|
||||
}
|
||||
],
|
||||
"startCommand": "./build/erlang-shipment/entrypoint.sh run"
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"assets": {
|
||||
"mise.toml": "[mise.toml]"
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"path": "/mise/shims"
|
||||
},
|
||||
{
|
||||
"customName": "create mise config",
|
||||
"name": "mise.toml",
|
||||
"path": "/etc/mise/config.toml"
|
||||
},
|
||||
{
|
||||
"cmd": "sh -c 'mise trust -a \u0026\u0026 mise install'",
|
||||
"customName": "install mise packages: erlang, gleam"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"image": "ghcr.io/railwayapp/railpack-builder:latest"
|
||||
}
|
||||
],
|
||||
"name": "packages:mise",
|
||||
"variables": {
|
||||
"MISE_CACHE_DIR": "/mise/cache",
|
||||
"MISE_CONFIG_DIR": "/mise",
|
||||
"MISE_DATA_DIR": "/mise",
|
||||
"MISE_INSTALLS_DIR": "/mise/installs",
|
||||
"MISE_NODE_VERIFY": "false",
|
||||
"MISE_SHIMS_DIR": "/mise/shims"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commands": [
|
||||
{
|
||||
"cmd": "gleam export erlang-shipment"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"step": "packages:mise"
|
||||
},
|
||||
{
|
||||
"include": [
|
||||
"."
|
||||
],
|
||||
"local": true
|
||||
}
|
||||
],
|
||||
"name": "build",
|
||||
"secrets": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"assets": {
|
||||
"mise.toml": "[mise.toml]"
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"path": "/mise/shims"
|
||||
},
|
||||
{
|
||||
"customName": "create mise config",
|
||||
"name": "mise.toml",
|
||||
"path": "/etc/mise/config.toml"
|
||||
},
|
||||
{
|
||||
"cmd": "sh -c 'mise trust -a \u0026\u0026 mise install'",
|
||||
"customName": "install mise packages: erlang"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"image": "ghcr.io/railwayapp/railpack-builder:latest"
|
||||
}
|
||||
],
|
||||
"name": "packages:mise:runtime",
|
||||
"variables": {
|
||||
"MISE_CACHE_DIR": "/mise/cache",
|
||||
"MISE_CONFIG_DIR": "/mise",
|
||||
"MISE_DATA_DIR": "/mise",
|
||||
"MISE_INSTALLS_DIR": "/mise/installs",
|
||||
"MISE_NODE_VERIFY": "false",
|
||||
"MISE_SHIMS_DIR": "/mise/shims"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package gleam
|
||||
|
||||
import (
|
||||
"github.com/railwayapp/railpack/core/generate"
|
||||
"github.com/railwayapp/railpack/core/plan"
|
||||
)
|
||||
|
||||
type GleamProvider struct{}
|
||||
|
||||
func (p *GleamProvider) Name() string {
|
||||
return "gleam"
|
||||
}
|
||||
|
||||
func (p *GleamProvider) Detect(ctx *generate.GenerateContext) (bool, error) {
|
||||
return ctx.App.HasFile("gleam.toml"), nil
|
||||
}
|
||||
|
||||
func (p *GleamProvider) Initialize(ctx *generate.GenerateContext) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *GleamProvider) StartCommandHelp() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (p *GleamProvider) Plan(ctx *generate.GenerateContext) error {
|
||||
build := ctx.NewCommandStep("build")
|
||||
build.AddInput(plan.NewStepLayer(ctx.GetMiseStepBuilder().Name()))
|
||||
build.AddInput(ctx.NewLocalLayer())
|
||||
build.AddCommand(plan.NewExecCommand("gleam export erlang-shipment"))
|
||||
|
||||
p.installErlang(ctx.GetMiseStepBuilder())
|
||||
ctx.GetMiseStepBuilder().Default("gleam", "latest")
|
||||
ctx.GetMiseStepBuilder().UseMiseVersions(ctx, []string{"gleam", "erlang"})
|
||||
|
||||
runtimeMiseStep := ctx.NewMiseStepBuilder("packages:mise:runtime")
|
||||
p.installErlang(runtimeMiseStep)
|
||||
runtimeMiseStep.UseMiseVersions(ctx, []string{"erlang"})
|
||||
|
||||
outPath := "build/erlang-shipment/."
|
||||
ctx.Deploy.AddInputs([]plan.Layer{
|
||||
runtimeMiseStep.GetLayer(),
|
||||
plan.NewStepLayer(build.Name(), plan.Filter{
|
||||
Include: []string{outPath},
|
||||
}),
|
||||
})
|
||||
|
||||
ctx.Deploy.StartCmd = "./build/erlang-shipment/entrypoint.sh run"
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *GleamProvider) installErlang(step *generate.MiseStepBuilder) {
|
||||
step.Default("erlang", "latest")
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/railwayapp/railpack/core/generate"
|
||||
"github.com/railwayapp/railpack/core/providers/deno"
|
||||
"github.com/railwayapp/railpack/core/providers/elixir"
|
||||
"github.com/railwayapp/railpack/core/providers/gleam"
|
||||
"github.com/railwayapp/railpack/core/providers/golang"
|
||||
"github.com/railwayapp/railpack/core/providers/java"
|
||||
"github.com/railwayapp/railpack/core/providers/node"
|
||||
@@ -35,6 +36,7 @@ func GetLanguageProviders() []Provider {
|
||||
&python.PythonProvider{},
|
||||
&deno.DenoProvider{},
|
||||
&node.NodeProvider{},
|
||||
&gleam.GleamProvider{},
|
||||
&staticfile.StaticfileProvider{},
|
||||
&shell.ShellProvider{},
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ export default defineConfig({
|
||||
{ label: "Deno", link: "/languages/deno" },
|
||||
{ label: "Rust", link: "/languages/rust" },
|
||||
{ label: "Elixir", link: "/languages/elixir" },
|
||||
{ label: "Gleam", link: "/languages/gleam" },
|
||||
{ label: "Staticfile", link: "/languages/staticfile" },
|
||||
{ label: "Shell Scripts", link: "/languages/shell" },
|
||||
],
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: Gleam
|
||||
description: Building Gleam applications with Railpack
|
||||
---
|
||||
|
||||
Railpack builds and deploys Gleam applications with zero configuration.
|
||||
|
||||
## Detection
|
||||
|
||||
Your project will be detected as a Gleam application if a `gleam.toml` file exists in the root directory.
|
||||
|
||||
## Versions
|
||||
|
||||
Both Gleam and Erlang default to the latest version; Erlang is available in both the build and runtime environments, but Gleam is only available during the build. This can be overridden with any mise-supported version file (`mise.toml`, `.tool-versions`, etc) or the `RAILPACK_PACKAGES` environment.
|
||||
|
||||
## Configuration
|
||||
|
||||
Railpack will build your Gleam application as an Erlang shipment using `gleam export erlang-shipment`, and run it using `./build/erlang-shipment/entrypoint.sh run`. By default, the source tree is not available in the final container.
|
||||
@@ -0,0 +1,4 @@
|
||||
*.beam
|
||||
*.ez
|
||||
/build
|
||||
erl_crash.dump
|
||||
@@ -0,0 +1 @@
|
||||
gleam 1.13.0
|
||||
@@ -0,0 +1,24 @@
|
||||
# app_gleam
|
||||
|
||||
[](https://hex.pm/packages/app_gleam)
|
||||
[](https://hexdocs.pm/app_gleam/)
|
||||
|
||||
```sh
|
||||
gleam add app_gleam@1
|
||||
```
|
||||
```gleam
|
||||
import app_gleam
|
||||
|
||||
pub fn main() -> Nil {
|
||||
// TODO: An example of the project in use
|
||||
}
|
||||
```
|
||||
|
||||
Further documentation can be found at <https://hexdocs.pm/app_gleam>.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
gleam run # Run the project
|
||||
gleam test # Run the tests
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
name = "app_gleam"
|
||||
version = "1.0.0"
|
||||
|
||||
gleam = ">= 1.13.0"
|
||||
|
||||
# Fill out these fields if you intend to generate HTML documentation or publish
|
||||
# your project to the Hex package manager.
|
||||
#
|
||||
# description = ""
|
||||
# licences = ["Apache-2.0"]
|
||||
# repository = { type = "github", user = "", repo = "" }
|
||||
# links = [{ title = "Website", href = "" }]
|
||||
#
|
||||
# For a full reference of all the available options, you can have a look at
|
||||
# https://gleam.run/writing-gleam/gleam-toml/.
|
||||
|
||||
[dependencies]
|
||||
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
|
||||
|
||||
[dev-dependencies]
|
||||
gleeunit = ">= 1.0.0 and < 2.0.0"
|
||||
@@ -0,0 +1,11 @@
|
||||
# This file was generated by Gleam
|
||||
# You typically do not need to edit this file
|
||||
|
||||
packages = [
|
||||
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
|
||||
{ name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
|
||||
]
|
||||
|
||||
[requirements]
|
||||
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
|
||||
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
|
||||
@@ -0,0 +1,5 @@
|
||||
import gleam/io
|
||||
|
||||
pub fn main() -> Nil {
|
||||
io.println("Hello from app_gleam!")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
[
|
||||
{
|
||||
"expectedOutput": "Hello from app_gleam!"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
*.beam
|
||||
*.ez
|
||||
/build
|
||||
erl_crash.dump
|
||||
@@ -0,0 +1,24 @@
|
||||
# app_gleam
|
||||
|
||||
[](https://hex.pm/packages/app_gleam)
|
||||
[](https://hexdocs.pm/app_gleam/)
|
||||
|
||||
```sh
|
||||
gleam add app_gleam@1
|
||||
```
|
||||
```gleam
|
||||
import app_gleam
|
||||
|
||||
pub fn main() -> Nil {
|
||||
// TODO: An example of the project in use
|
||||
}
|
||||
```
|
||||
|
||||
Further documentation can be found at <https://hexdocs.pm/app_gleam>.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
gleam run # Run the project
|
||||
gleam test # Run the tests
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
name = "app_gleam"
|
||||
version = "1.0.0"
|
||||
|
||||
gleam = ">= 1.13.0"
|
||||
|
||||
# Fill out these fields if you intend to generate HTML documentation or publish
|
||||
# your project to the Hex package manager.
|
||||
#
|
||||
# description = ""
|
||||
# licences = ["Apache-2.0"]
|
||||
# repository = { type = "github", user = "", repo = "" }
|
||||
# links = [{ title = "Website", href = "" }]
|
||||
#
|
||||
# For a full reference of all the available options, you can have a look at
|
||||
# https://gleam.run/writing-gleam/gleam-toml/.
|
||||
|
||||
[dependencies]
|
||||
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
|
||||
|
||||
[dev-dependencies]
|
||||
gleeunit = ">= 1.0.0 and < 2.0.0"
|
||||
@@ -0,0 +1,11 @@
|
||||
# This file was generated by Gleam
|
||||
# You typically do not need to edit this file
|
||||
|
||||
packages = [
|
||||
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
|
||||
{ name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
|
||||
]
|
||||
|
||||
[requirements]
|
||||
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
|
||||
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
|
||||
@@ -0,0 +1,5 @@
|
||||
import gleam/io
|
||||
|
||||
pub fn main() -> Nil {
|
||||
io.println("Hello from app_gleam!")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
[
|
||||
{
|
||||
"expectedOutput": "Hello from app_gleam!"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user