Deploy Your Own Instance of App inventor for free

Hi everybody,
I made a GitHub action that builds the app inventor, then builds the docker image and pushes it to the docker registry. The server.sh and dockerfile below are for just the frontend and gwt parts except for the build server. To run the build server, the last line of the server.sh needs to be replaced by ant RunLocalBuildServer and the EXPOSE 8888 in dockerfile be replaced with EXPOSE 9990 and the dockerfile needs to be built again.

Add the files below to their respective paths, Dockerfile and server.sh should be in root of the directory.

.github/workflows/docker-image.yml
name: Build UI

on: [workflow_dispatch]

jobs:
  build_push_docker:
name: Push Docker image to Docker Hub after building
runs-on: ubuntu-latest
steps:
  - name: Check out the repo
    uses: actions/checkout@v2
  
  - name: 'Set up JDK 1.8'
    uses: actions/setup-java@v1
    with:
      java-version: 8
      
  - name: 'Checkout submodules'
    uses: textbook/git-checkout-submodule-action@master
    
  - name: 'Install 32-bit dependencies'
    run: sudo apt-get install -y libc6-i386 lib32z1 lib32stdc++6 ant
    
  - name: 'Make Auth Key'
    run: ant MakeAuthKey
    
    working-directory: appinventor
  - name: 'Build Appinventor'
    run: ant noplay        
    working-directory: appinventor

  
  - name: Log in to Docker Hub
    uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
    with:
      username: ${{ secrets.DH_USERNAME }}
      password: ${{ secrets.DH_PASSWORD }}
  
  - name: Extract metadata (tags, labels) for Docker
    id: meta
    uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
    with:
      images: ${{ secrets.DH_USERNAME }}/ai2
      
  - name: Build and push Docker image
    uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
    with:
      context: .
      push: true
      tags: ${{ secrets.DH_USERNAME }}/ai2:${{ github.sha }}
      labels: ${{ secrets.DH_USERNAME }}/ai2:${{ github.sha }}
Dockerfile
FROM openjdk:8 
 
ENV HOME /home/developer 
 
WORKDIR $HOME 
 
COPY . . 
 
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg  add - && apt-get update -y && apt-get install google-cloud-sdk -y 
 
RUN apt-get install -y  ant 
 
RUN curl 'https://storage.googleapis.com/appengine-sdks/featured/appengine-java-sdk-1.9.84.zip' > /tmp/appengine.zip \ 
 && unzip -d $HOME /tmp/appengine.zip \ 
 && rm /tmp/appengine.zip \ 
 && ln -s $HOME/appengine-java-sdk-1.9.84 $HOME/appengine 

EXPOSE 8888 
      
CMD chmod 777  server.sh && ./server.sh
server.sh
#!/bin/bash
set -e

cd appinventor

/home/developer/appengine/bin/dev_appserver.sh --port=8888 --address=0.0.0.0 appengine/build/war/

Now you can deploy that image anywhere, on platforms such as https://railway.app allow you to deploy docker images for free, so go and try that. You can also try the https://ai2.up.railway.app hosted there.

How to deploy?

Simple, just make a new github repo by going to repo.new and add the image name in the dockerfile.

Dockerfile:
FROM your-dockerhub-username/ai2:tag

replace your-dockerhub-username with the dockerhub username and tag with the latest github commit sha on your repo where the github action was run.

Deploy Buildserver

Note: its not recommended to deploy the buildserver with environments with low RAM limits as it may fail, tho if you want to still do it, then follow along.

Deploying this on a different environment in the same railway project, gives it a full 1GB RAM and builds may succeed.

To dockerize the buildserver you follow the same GitHub action but with a different Dockerfile and server.sh file. The updated ones for buildserver are given below:

Dockerfile
FROM openjdk:8 
 
ENV HOME /home/developer 
 
WORKDIR $HOME 
 
COPY . . 
 
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg  add - && apt-get update -y && apt-get install google-cloud-sdk -y 
 
RUN apt-get install -y  ant 
 
RUN curl 'https://storage.googleapis.com/appengine-sdks/featured/appengine-java-sdk-1.9.84.zip' > /tmp/appengine.zip \ 
 && unzip -d $HOME /tmp/appengine.zip \ 
 && rm /tmp/appengine.zip \ 
 && ln -s $HOME/appengine-java-sdk-1.9.84 $HOME/appengine 

EXPOSE 9990
      
CMD chmod 777  server.sh && ./server.sh
server.sh
#!/bin/bash
set -e

cd appinventor

ant RunLocalBuildServer

Thanks For Reading!

7 Likes

:grin:
This is the guide by person that helped me deploy my instance for free
:heart_eyes:

Thank You :grinning:

@Hrichik_Mazumder Maybe you can elaborate about build server one too
:upside_down_face:

1 Like

Sure, I am updating the post soon.

Update: Post updated :D

Great guide! @Hrichik_Mazumder

However, as far as I can tell it would create a development server and not a production server. So if we run ant clean all the projects / any data would be purged.

This could be overcomed with the PostgreSQL PR in the Appinventor repository I think.

1 Like

Ya, of course, you don't want production data to be wiped out every deployment. The docker container method I described here is for just showing some changes to interact with, and for production, you should use a Google Cloud Datastore added in the code somewhere, then if you deploy with docker, it should be fine...

1 Like

Great guide!!

Amazing ! Was looking for this type of thing :grin:

Note:

Railway.app has reduced the free tier limits and as I see, it would not be able to handle the appinventor as a whole their, so you many try tweaking a few things and trying with a different platform as many platforms support docker nowadays.

2 Likes