Quickstart Guides

A Dockerfile is a file that contains instructions for building an image that can be run on a Docker container. In Runnable, we use Dockerfiles to build and run images based on your code.

If your app doesn’t use Dockerfiles, don’t worry! this guide will show you how to generate them from your source code and settings you configure. Then we’ll point you to the next steps for setting up your application.

Note: Creating Dockerfiles is a great way to start using Runnable, but some features are reserved for apps that use Docker Compose:

  • Automatically creating isolated stacks for branches
  • Running automated tests

1. Adding Your Repository

Select a language to customize this guide for your repository. If none apply, you can still follow along.

First you’ll need to add the Node.js repository that you want to create a Dockerfile for. From the Containers page, click the Add Services button and select it from the list.

In the modal that appears, click the No Compose File tab and select Start with our setup guide.


2. Configuring the Basics

The next steps will walk you through the configuration of your repository.

Repository

First you’ll set the base image for your Dockerfile. Select the Node.js stack type and the versions of version of Node.jsversion of Pythonversions of Ruby and Railsversion of PHP that your repository requires for runtime.


Commands and Packages

Use this tool to specify the commands your repository needs to build and run.

Packages

This section is where you can install any tools, libraries, or frameworks your repository needs from the Ubuntu Aptitude library.

Build Commands

You can add commands for building your application. For example, you may want to add commands for building your CSS or minifying your JavaScript. These commands will run in the root folder of the repository when its container is building.

For your PHP app, you’ll need to add the following commands to this section:

Set permissions for your application directory:

$ chgrp -R www-data /var/www/html/
$ chmod -R 775 /var/www/html/storage

Copy Laravel’s .env.example to .env in your application directory:

$ cp .env.example .env

Generate your application key:

$ php artisan key:generate

Container CMD

You’ll need to define your application’s run command, such as npm startpython main.pyrails serverapache2-foreground.

Note: The container will stop running when this command exits.

Here are some pointers for this section:

  • It’s typically a good idea to bind to all interfaces using -b 0.0.0.0 as part of this line so the container can be accessed through the browser and by other containers. For example: npm start -b 0.0.0.0python manage.py -b 0.0.0.0rails server -b 0.0.0.0apache2-foreground -b 0.0.0.0
  • If you’ve already added a database, you may need to use && to run migration commands after your main run command. For example: npm run migrations && npm startpython manage.py migrate && python manage.py runserver 0.0.0.0:80rails server && rake db:migratephp artisan migrate && apache2-foreground

After configuring Commands and Packages, you’re good to go. You can view the Dockerfile we’ve generated in the Dockerfile tab, and you can click the Save & Build button to start building a container from that Dockerfile.


3. Additional Configuration

Many applications will need more setup. We’ll walk you through the remaining tools you may need.

Exposed Ports

You can expose any ports your container will use to communicate with other containers. Port 3000300080003306 is commonly exposed for Node.js apps.


Environment Variables

You can add environment variables to set configuration values or secrets that you don’t want to check into your repository. These values will be added to your container’s environment when it runs.

If you’ve added other services to Runnable (like databases or other repositories), you can also use this tool to point your repository to their URLs.

For example: If your service uses MONGO_URL to set the URL for your database, you can add MONGO_URL=mongodb-staging-myorg.runnableapp.com.


Files & SSH Keys

Add any external assets that your application needs to build and run, like configuration files, other GitHub repositories, or SSH keys.

If you have hard-coded values in your repository that need to be changed, you can also use this tool to override those values by uploading modified files to the same paths.

For more details, read about adding persistent files to your container.

For more details, read about adding persistent files to your container.

For more details, read about adding persistent files to your container.

For your PHP app, you’ll need to upload your Laravel apache2 configuration file (laravel.conf).

Add this path for its Destination:

/etc/apache2/sites-available

And add these Scripts:

a2ensite laravel.conf
a2enmod rewrite]

Next Steps

Once your repository is up and running, you can interact with the terminal, or you can open its URL to view its web output.

By default, you’ll also get new environments for branches of this repository when you push to GitHub. Pushes from other collaborators who have joined Runnable will also trigger new environments.

You can follow this guide again to add and set up any other repositories in your app.


What’s next?