Blog

Effortless Deployment: Launching Your BoxLang Miniserver!

Maria Jose Herrera July 23, 2024

Spread the word

Maria Jose Herrera

July 23, 2024

Spread the word


Share your thoughts

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

  1. 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.

  1. Create an empty github project on github.com

  1. 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.

  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.

  1. 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


  1. 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'

  1. 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.

  1. 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.

  1. 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.

  1. 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

Recent Entries

BoxLang 1.0.0 Beta 7 Launched

BoxLang 1.0.0 Beta 7 Launched

We are pleased to announce the release of BoxLang 1.0.0-Beta 7! This latest beta version includes improvements and essential bug fixes, but more importantly it certifies the execution of ColdBox HMVC and TestBox.

What is BoxLang?

BoxLang is a modern dynamic JVM language that can be deployed on multiple runtimes: operating system (Windows/Mac/*nix/Embedded), web server, lambda, iOS, android, web assembly, and more. BoxLang combines many features from different progr

Luis Majano
Luis Majano
July 26, 2024
New BoxLang Feature: Java Method References and Higher-Order Functions

New BoxLang Feature: Java Method References and Higher-Order Functions

We’ve added more goodies to our BoxLang Java interop: method references and higher-order functions. CFML has never let you do these things, making Java Interop feel like a second-class citizen. But with BoxLang, we’re elevating Java integration to a new level.

Maria Jose Herrera
Maria Jose Herrera
July 26, 2024
Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Are you a CFML developer looking to take your skills to the next level? Look no further than the ColdBox from Zero to Hero Virtual Live Training! This intensive two-day course will equip you with the knowledge and expertise to build robust and scalable applications using ColdBox 7, the latest version of the most popular CFML MVC framework.

What You'll Learn:

  • Master the Fun...

Cristobal Escobar
Cristobal Escobar
July 24, 2024