Deploying your App
Packaging Moose for deployment

Packaging Moose for deployment

Once you've developed your Moose application locally, you can package it for deployment to your on-prem or cloud infrastructure.

The first step is to navigate (cd) to your moose project in your terminal.

Terminal
cd my-moose-project

The Moose CLI you've used to build your Moose project also has a handy flag that will automate the packaging and building of your project into docker images.

Terminal
npx @514labs/moose-cli build --docker

After the above command completes you can view your newly created docker files by running the docker images command:

Terminal
>docker images
REPOSITORY                                              TAG               IMAGE ID       CREATED              SIZE
moose-df-deployment-aarch64-unknown-linux-gnu           latest            c50674c7a68a   About a minute ago   155MB
moose-df-deployment-x86_64-unknown-linux-gnu            latest            e5b449d3dea3   About a minute ago   163MB

Notice that you get two moose-df-deployment containers, one for the aarch64 (ARM64) architecture and another for the x86_64 architecture. This is necessary to allow you to choose the version that matches your cloud or on-prem machine architecture.

You can then use standard docker commands to push your new project images to your container repository of choice.

First tag your local images:

Terminal
docker tag moose-df-deployment-aarch64-unknown-linux-gnu:latest {your-repo-user-name}/moose-df-deployment-aarch64-unknown-linux-gnu:latest
docker tag moose-df-deployment-x86_64-unknown-linux-gnu:latest {your-repo-user-name}/moose-df-deployment-x86_64-unknown-linux-gnu:latest

Then push your files to your container repository.

Terminal
docker push {your-repo-user-name}/moose-df-deployment-aarch64-unknown-linux-gnu:latest
docker push {your-repo-user-name}/moose-df-deployment-x86_64-unknown-linux-gnu:latest

You can also use the following handy shell script to automate the steps above.

push.sh
#!/bin/bash
 
version=$2
 
if [ -z "$1" ]
then
      echo "You must specify the dockerhub repository as an argument. Example: ./push.sh container-repo-name"
      echo "Note: you can also provide a second argument to supply a specific version tag - otherwise this script will use the same version as the latest moose-cli on Github."
      exit 1
fi
 
if [ -z "$2" ]
then
      output=$(npx @514labs/moose-cli -V)
      version=$(echo "$output" | sed -n '2p' | awk '{print $2}')
fi
 
echo "Using version: $version"
arch="moose-df-deployment-aarch64-unknown-linux-gnu"
docker tag $arch:$version $1/$arch:$version
docker push $1/$arch:$version
 
arch="moose-df-deployment-x86_64-unknown-linux-gnu"
docker tag $arch:$version $1/$arch:$version
docker push $1/$arch:$version