From 323ddc3ae1bd655892a5b3eee68411dce0c38c3a Mon Sep 17 00:00:00 2001 From: Denny Pradipta Date: Mon, 31 Jan 2022 15:24:16 +0700 Subject: [PATCH] Docs: Deploy to Fly.io (#587) * feat: fly.toml * docs: deploy to fly.io * fix: Dockerfile fly.io * fix: monika dockerfly io --- .gitignore | 3 ++ Dockerfile.flyio | 18 ++++++++ docs/src/manifests/manifest.json | 11 +++++ docs/src/pages/deployment/deploy-to-fly-io.md | 45 +++++++++++++++++++ fly.toml.example | 18 ++++++++ 5 files changed, 95 insertions(+) create mode 100644 Dockerfile.flyio create mode 100644 docs/src/pages/deployment/deploy-to-fly-io.md create mode 100644 fly.toml.example diff --git a/.gitignore b/.gitignore index 3fefcd848..e8056c46b 100644 --- a/.gitignore +++ b/.gitignore @@ -232,3 +232,6 @@ monika.yaml # IntelliJ .idea/ + +# Fly.io +fly.toml diff --git a/Dockerfile.flyio b/Dockerfile.flyio new file mode 100644 index 000000000..95fae156b --- /dev/null +++ b/Dockerfile.flyio @@ -0,0 +1,18 @@ +FROM node:14-alpine + +RUN apk add --no-cache --virtual .gyp python3 make g++ + +# Setup environment variables +ARG PARAMS +ENV PARAMS=${PARAMS} +ENV CI=true + +# Install Monika +USER node +RUN mkdir /home/node/.npm-global +ENV PATH=/home/node/.npm-global/bin:$PATH +ENV NPM_CONFIG_PREFIX=/home/node/.npm-global +RUN npm install -g @hyperjumptech/monika + +# Run Monika with Params +CMD ["sh", "-c", "${NPM_CONFIG_PREFIX}/bin/monika ${PARAMS}"] diff --git a/docs/src/manifests/manifest.json b/docs/src/manifests/manifest.json index bd187f4a2..de7aff24b 100644 --- a/docs/src/manifests/manifest.json +++ b/docs/src/manifests/manifest.json @@ -98,6 +98,17 @@ } ] }, + { + "title": "Deployment", + "heading": true, + "routes": [ + { + "title": "Deploy to Fly.io", + "path": "/deployment/deploy-to-fly-io", + "editUrl": "/deployment/deploy-to-fly.io.md" + } + ] + }, { "title": "Tutorial", "heading": true, diff --git a/docs/src/pages/deployment/deploy-to-fly-io.md b/docs/src/pages/deployment/deploy-to-fly-io.md new file mode 100644 index 000000000..52256f596 --- /dev/null +++ b/docs/src/pages/deployment/deploy-to-fly-io.md @@ -0,0 +1,45 @@ +--- +id: deploy-to-fly-io +title: Deploy to Fly.io +--- + +This article covers how to deploy a Monika instance to Fly.io. + +1. Go to the [Monika Github repository](https://github.com/hyperjumptech/monika) and download two files: Dockerfile.flyio and fly.toml.example + +2. Rename the `fly.toml.example` to fly.toml`. + +3. Edit the contents of the fly.toml: + + ```toml + app = "monika" # Change the app name to the desired name + + kill_signal = "SIGINT" + kill_timeout = 5 + + [build] + dockerfile = "Dockerfile.flyio" + + [build.args] + PARAMS = "-v" # Change the parameters according to your needs + + [env] + PARAMS = "-v" # Match the content of this PARAMS variable to the one in `build.args` block + + [experimental] + auto_rollback = true + ``` + + Refer to the [Fly.io App Configuration Docs](https://fly.io/docs/reference/configuration/) to customize the example TOML even further. + +4. Install [Fly.io CLI tools](https://fly.io/docs/flyctl/installing/) (`flyctl`) in your computer + +5. a. Proceed to authenticate to Fly.io by running `flyctl auth login` in your terminal. + + b. If you haven't signed up to Fly.io yet, you can sign up by running `flyctl auth signup` in your terminal. + +6. Create a new Fly.io app by running `flyctl apps create` and enter the app name according to your `fly.toml` you have created before. + +7. Deploy Monika to your Fly.io by running `flyctl deploy` + +8. Wait until the deployment is finished, and check Monika logs from the Fly.io dashboard to confirm that your Monika instance is running. diff --git a/fly.toml.example b/fly.toml.example new file mode 100644 index 000000000..27f9529f2 --- /dev/null +++ b/fly.toml.example @@ -0,0 +1,18 @@ +app = "monika" + +kill_signal = "SIGINT" +kill_timeout = 5 + +[build] +dockerfile = "Dockerfile.flyio" + +[build.args] +# Insert your Monika parameters +PARAMS = "-v" + +[env] +# Insert your Monika parameters +PARAMS = "-v" + +[experimental] +auto_rollback = true