menuCohesive docs

Consider a React app which uses a MariaDB database. To create a project:

Add a new project

add-a-new-project

  1. Click on New project button to add a new project.
  2. Enter the name of git repository, the name for your project and simply select the git branch.
  3. Click on Create project button.

Add a deployment configuration

deployment-config

  1. Click on Create configuration button.
  2. Enter the name and description of the configuration and click save.

Configure MariaDB database

  1. Click on Services, select MariaDB and click Continue.
  2. Add a name for your service.
  3. Specify the amount of CPU, memory and storage required by your service.
  4. You can add a MariaDB file to initialize the service.
  5. Click on Create service button.

Add your application

  1. Click on Applications, select Javascript and click Continue.
  2. Add name for your application.
  3. Select protocols required by your application and specify their ports - click on the dropdown (right column) to select the protocol and enter the corresponding port number (left column).
  4. Specify the amount of CPU and memory required by your application at run time. A lower CPU/Memory allocation would have lower costs, but can have worse performance. If the value is too low, your application might fail with Out Of Memory error.

Specify build instructions

To specify build instructions, you can either add a Dockerfile or provide Manual instructions.

Using Dockerfile

  1. Click Dockerfile
  2. Add the dockerfile to your codebase. Here is a sample Dockerfile for a React application:
# Dockerfile

FROM node:lts-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
COPY . .
EXPOSE 3000
RUN chown -R node /usr/src/app
USER node
CMD ["node", "main.js"]
  1. Specify path to your Dockerfile. Eg: If your Dockerfile is in your root folder, the path will be ./<filename>. If it is insode some other folder (say orders folder), the path will be orders/<filename>
  2. Specify build aguments if needed. Build arguments are arguments that are required at build time of the application. These will be passed to your dockerfile as arguments.
  3. Add Advanced instructions if needed.

Using manual instructions

Click on Manual instructions and add:

  1. Base image: The base docker image you want to use for building your application. Eg: FROM node:lts-alpine
  2. Os Package Install Command: Command to install all the OS level packages your application needs at build time and runtime.
  3. Application Dependency Path: The path to the file that contains dependencies of your appligation. This should be relative to Working Directory. In this case, it will be path to package.json file.
  4. Application Package Install Command: This command will be used to install packages listed in the application dependency path. Eg: npm install
  5. Application Build Command: This command will be used to build your application. Eg: npm run build
  6. Application Run Command: This command will be used to run your application. Do not put application run command anywhere else. Eg: npm start
  7. Add Advanced instructions if needed.

Add environment variables

Environment variables can either be manually added or directly imported from JSON files. Eg:

{
    "environment": "dev",
    "host": "{{mariadb.Host}}",
    "port": "{{mariadb.Port}}",
    "username": "{{mariadb.Username}}",
    "password": "{{mariadb.Password}}",
    "database": "{{mariadb.Database}}"
}

After setting up the services, applications, and infrastructure configurations, click on Create configuration.

Advanced instructions

  1. Pre-build script: This will run right before your application is built. Generating static files, env files or pulling private dependencies are some things that can be done here. This will run in the Working Directory.
  2. Working directory: This is where your container image is built. Pre build script and build commands will run here.
  3. Build resources: The maximum amount of resources required for your application to be built.
  4. Volumes: Persistent storage required by your application.