Preparing an app
- Track your codebase in a Git repository
- Add a Codemason Git remote
- Prepare codebase for deployment
- Next steps
Track your codebase in a Git repository
Codemason relies heavily on Git, a popular version control system. Before you can deploy your codebase with Codemason, it must be a Git repository.
You can initialise a git repository in the current folder by running:
$ git init
Once initialised, you can add and commit your files with
git add . git commit -m "Creating my first Codemason app"
Learn more about Git
Add a Codemason Git remote
For a new app
Every Codemason app has it's own Codemason Git repository. You can deploy new versions of your app by pushing your changes to this repo. To do this, you local Git repo needs to have Codemason added as a remote.
mason create command will create a new empty app on Codemason and a corresponding empty Codemason Git repository for your app. The Codemason Git repo will be automatically added as a remote in your local repository.
$ mason create pebble Creating app on Codemason... ... Created application ... Created remote repository ... Added git remote codemason
Confirm that a remote named
codemason has been set with the
git remote command
$ git remote -v codemason [email protected]:my-team/pebble (fetch) codemason [email protected]:my-team/pebble (push)
For an existing app
If you have already created a Codemason app, you can easily add a remote to your local repo with the
mason git:remote command
$ mason git:remote pebble
Prepare codebase for deployment
The most important part of preparing your codebase for deployment is building it into a Docker image. Codemason does this by looking for a
Dockerfile in the root directory of your app.
NOTE: You can create these files automatically for most major languages and frameworks using Craft Kits
.gitlab-ci.yml file is what tells Codemason how to build your app. It works just like any normal GitLab CI/CD Pipeline Configuration.
Here is an example
stages: - build services: - docker:dind before_script: - docker login -u=gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY build: stage: build script: - docker build -t $CI_REGISTRY_IMAGE:latest . - docker push $CI_REGISTRY_IMAGE:latest
Dockerfile tells Codemason (and Docker) how to run your app. Codemason provides a set of "sensible defaults" for most languages so you do not need to be familiar with Docker to get started.
Here is an example
Remember to commit these new files to source control
$ git add . $ git commit -m "Preparing codebase for Codemason"
After you have prepared your app, you are ready to create an app.