Gigalixir is a fully-featured, production-stable platform-as-a-service built just for Elixir that saves you money and unlocks the full power of Elixir and Phoenix without forcing you to build production infrastructure or deal with maintenance and operations. For more information, see https://gigalixir.com.
Try Gigalixir for free without a credit card by following the Getting Started Guide.
Gigalixir 是专为 Elixir 构建的功能齐全、生产稳定的「平台即服务」,它可以在低成本的情况下部署使用 Elixir & Phoniex 服务,而无需构建生产基础设施或处理维护和操作。有关更多信息,请参阅 https://gigalixir.com。
Based on Arweave's FaaS system, code snippets written in languages such as Elixir/Rust can be pulled from the Arweave Network and loaded into Runtime to provide functional service support for other applications. Plugin is used for uploading code snippets.
基于 Arweave 的 Micro FaaS 系统,任何人都可以快捷方便地启动,可以从 Arweave 网络中提取 Elixir/Rust 等语言编写(取决于 FaaS 的语言版本)的代码片段并加载到 Runtime 中,为其他应用程序提供功能服务支持。
此外还提供用于上传代码片段的 dApp 插件。
FaaS Repo:
https://github.com/WeLightProject/tai_shang_micro_faas_system
- For macOS
brew. For help, take a look at the homebrew documentation.
git. For help, take a look at the git documentation.
- For Linux
python3. python2 also works, but it is EOL as of January 1st, 2020. pip3. For help, take a look at the pip documentation. git. For help, take a look at the git documentation. For example, run
sudo apt-get update
sudo apt-get install -y python3 python3-pip git-core curl
- For Windows
python3. python2 also works, but it is EOL as of January 1st, 2020. pip3. For help, take a look at the pip documentation. git. For help, take a look at the git documentation.
Next, install the command-line interface. Gigalixir has a web interface at https://console.gigalixir.com/, but you will likely still want the CLI.
- For macOS
brew tap gigalixir/brew && brew install gigalixir
- For Linux
pip3 install gigalixir --user
And then make sure the executable is in your path, if it isn’t already.
echo 'export PATH=~/.local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
- For windows
pip3 install gigalixir --user
Make sure the executable is in your path, if it isn’t already.
Verify by running
gigalixir --help
If you already have an account, skip this step.
gigalixir signup
Next, log in. This will grant you an api key. It will also optionally modify your ~/.netrc file so that all future commands are authenticated.
gigalixir login
Verify by running
gigalixir account
git clone https://github.com/WeLightProject/tai_shang_micro_faas_system.git
cd tai_shang_micro_faas_system
APP_NAME=$(gigalixir create -n faasex) #Attention: the name should be unique in gigalixir.
Verify that the app was created, by running
gigalixir apps
Verify that a git remote was created by running
git remote -v
- Check
.buildpacks
https://github.com/emk/heroku-buildpack-rust
https://github.com/HashNuke/heroku-buildpack-elixir
https://github.com/gjaldon/heroku-buildpack-phoenix-static
https://github.com/gigalixir/gigalixir-buildpack-mix.git
- Check
elixir_buildpack.config
elixir_version=1.13.3
erlang_version=24.3.2
hook_post_compile="mkdir -p assets/node_modules"
- Check
RustConfig
RUST_SKIP_BUILD=1
- Check
phoenix_static_buildpack.config
node_version=14.15.4
clean_cache=false
- Check
assets/package.json
{
"scripts": {
"deploy": "cd .. && mix assets.deploy && rm -f _build/esbuild"
}
}
- Check
config/prod.exs
## ...
config :tai_shang_micro_faas_system, TaiShangMicroFaasSystemWeb.Endpoint,
http: [port: {:system, "PORT"}], # Possibly not needed, but doesn't hurt
url: [host: System.get_env("APP_NAME") <> ".gigalixirapp.com", port: 443],
secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE"),
server: true
config :tai_shang_micro_faas_system, TaiShangMicroFaasSystem.Repo,
adapter: Ecto.Adapters.Postgres,
url: System.get_env("DATABASE_URL"),
ssl: true,
pool_size: 2 # Free tier db only allows 4 connections. Rolling deploys need pool_size*(n+1) connections where n is the number of app replicas.
Don’t forget to commit if you change something.
git add .
git commit -m "assets deploy script"
gigalixir pg:create --free
Verify by running
gigalixir pg
Finally, build and deploy.
git push gigalixir
gigalixir run mix ecto.migrate
# this is run asynchronously as a job, so to see the progress, you need to run
gigalixir logs
Run seeds
gigalixir run -- mix run priv/repo/seeds.exs
Wait a minute or two for the app to pass health checks. You can check the status by running
gigalixir ps
Verify it works
curl https://$APP_NAME.gigalixirapp.com/
# or you could also run
# gigalixir open
Now you can run gigalixir open
to open your own website.
If you get error, please try to clean your build cache and then try agin.
git -c http.extraheader="GIGALIXIR-CLEAN: true" push gigalixir
After first deploy, you can see app by visiting https://$APP_NAME.gigalixirapp.com/ .
but if you want, you can point your own domain such as www.example.com to your app. To do this, run the following command and follow the instructions.
gigalixir domains:add www.example.com
This will do a few things. It registers your fully qualified domain name in the load balancer so that it knows to direct traffic to your containers. It also sets up SSL/TLS encryption for you and provisions a certificate.
You can also add domain by visiting https://console.gigalixir.com/#/apps/
with UI style.
You may need to change your check_origin setting in order for websockets to pass the origin check.
Verify your runtime.exs
:
config :tai_shang_micro_faas_system, TaiShangMicroFaasSystemWeb.Endpoint,
http: [
# Enable IPv6 and bind on all interfaces.
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: String.to_integer(System.get_env("PORT") || "4000")
],
secret_key_base: secret_key_base,
check_origin: false
All app configuration is done through environment variables. You can get, set, and delete configs using the following commands. Note that setting configs automatically restarts your app.
FaaS admins can use all valid code snippet stored on AR network via Tx ID
(Code Market will be launched in the future)! Through the Add new Function by Tx id
page, admins can dynamically pull the code from the Arweave network. Uploading the code is achieved through dApp/Plugin
which is decoupled from FaaS. We use System.get_env("ADMIN_PASSWD")
to get ADMIN_PASSWD environment variable.
So that, we can set or unset ADMIN_PASSWD
like this:
gigalixir config
gigalixir config:set ADMIN_PASSWD=bar
gigalixir config:unset ADMIN_PASSWD