Deploying a BoxLang Miniserver Website to Render.com Using Github Actions
Deploying a BoxLang mini-server website to Render.com can be straightforward and efficient when using a Docker image built with GitHub Actions. This Guest blog post is presented to you by one of our amazing community members Daniel Mejía, who will guide you through the process, detailing each step to ensure a smooth deployment.
Quick Overview
The deployment process allows you to commit changes to your website code on GitHub. The GitHub action will automatically build the container image and push it to the GitHub Container Registry. Finally, an HTTP GET request to the Render.com redeploy webhook deploys the container image with the latest code changes. The entire process, from committing on your machine to a live deployment on Render.com, takes about 90 seconds!
Why is this Relevant to You?
- Cost-Effective: Github is free, Github Container Registry is free, and the free tier on Render.com provides 0.1 CPU and 512MB RAM. Although it shuts down after 8 minutes of inactivity, the startup time is only about 45 seconds. This setup is ideal for a hobby web app with zero users.
- Simplicity: This method requires minimal configuration and no credit card, making it accessible and easy to implement.
Requirements
- GitHub Account github.com
- Render.com Account
- Any secrets vault (Keepersecurity.com/vault is recommended)
Steps to Configure and Deploy
- Create a GitHub Personal Access Token
- Click on Profile picture and then Settings, then Developer Settings, then create a Classic Token.
- Save this token in your secrets vault.
- Create an empty github project on github.com
- Create a new Repository Secret
- Go to your repository on github.com, then Settings. Then go to Actions under Secrets and Variables. Create a new repository secret - give it the name GH_PAT and the value should be your Personal Access Token you created in step 1.
- Create Your "Hello World" app
- Create a new folder/project on your development machine.
- At the root of your project create an index.bmx file. Add your html to this file and save it.
- Create a file named dockerfile (no extension, no periods) at the root of your project.
FROM ortussolutions/boxlang:miniserver-alpine
RUN rm /app/* -r
COPY ./ /app
- Create a .github/workflows/publish-container.yaml (two folders deep)
name: Docker Image CI for GHCR Boxlang
on:
push
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and push the image
run: |
docker login --username <github-username-goes-here> --password ${Setting: {secrets.GH_PAT not found}} ghcr.io
docker build . --tag ghcr.io/<github-name-goes-here>/<image-name-goes-here>:latest
docker push ghcr.io/<github-name-goes-here>/<image-name-goes-here>:latest
- name: Render.com Redeploy Webhook
uses: fjogeleit/http-request-action@v1
with:
url: 'https://google.com'
method: 'GET'
- Git commit and push your code up to github.com
- This will start an action under your project’s Actions. The part that builds the docker container and pushes it to ghcr.io should succeed. The part for Render.com will fail.
- Create an account at Render.com
- Create a New Web Service. Use the "Existing Image" option. The URL of your image will be "https://ghcr.io/
/ : ". For example, mine is: ghcr.io/webmandman/hello-world-ghcr - The image is private by default, so you must supply your GitHub personal access token.
- Create a New Web Service. Use the "Existing Image" option. The URL of your image will be "https://ghcr.io/
- Get Your Render.com Redeploy URL
- Go to the settings of your new service. Look for Redeploy Hook. Save this URL to your publish-container.yaml file, replacing the google.com URL.
- Git commit and push your code up to github.com
- This time, watch every part of the Action succeed and then head over to Render.com. Under your web service Events tab you’ll see the status of the deployment. Once it succeeds you can visit your web app at the URL provided by Render.com. Mine is https://hello-world-ghcr-latest.onrender.com/
Note: The cold start of this web app is about 45 seconds - that is pretty slow, but then again it’s free and you don't need a credit card. You can upgrade your service anytime if you want zero downtime.
Conclusion
This method is as simple as it gets, whether or not you use GitHub Container Registry or Render.com It should be similar to other modern services, requiring only two configuration files and two service accounts. This streamlined process, with no credit card required, makes deploying a BoxLang Miniserver website accessible and efficient for all.
By following these steps, you can achieve an efficient deployment workflow, ensuring your BoxLang Miniserver website is live and up-to-date with minimal effort.
Guest Writer: Daniel Mejía
Who is responsible for this useful information for all? This amazing blog post has been crafted for all of us by Daniel Mejía a Web Applications Development Manager at Psomas. with a demonstrated history of working in IT for the civil engineering industry, and personal care e-commerce industry. Advanced proficiency in Javascript, HTML, CSS, ColdFusion, and SQL - all of which are backed by at least 8+ years of experience. Expert in creating full-stack applications for enterprises and consumers. Learn More
Happy deploying!
Add Your Comment