All Projects → Recruitee → Mix_docker

Recruitee / Mix_docker

Licence: mit
Put your Elixir app production release inside minimal docker image

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Mix docker

Distillery
Every alchemist requires good tools, and one of the greatest tools in the alchemist's disposal is the distillery. The purpose of the distillery is to take something and break it down to its component parts, reassembling it into something better, more powerful. That is exactly what this project does - it takes your Mix project and produces an Erlang/OTP release, a distilled form of your raw application's components; a single package which can be deployed anywhere, independently of an Erlang/Elixir installation. No dependencies, no hassle.
Stars: ✭ 2,869 (+756.42%)
Mutual labels:  deployment
Production Level Deep Learning
A guideline for building practical production-level deep learning systems to be deployed in real world applications.
Stars: ✭ 3,358 (+902.39%)
Mutual labels:  deployment
Ansible Rails
Ansible: Ruby on Rails Server
Stars: ✭ 317 (-5.37%)
Mutual labels:  deployment
Appimageupdate
AppImageUpdate lets you update AppImages in a decentral way using information embedded in the AppImage itself.
Stars: ✭ 261 (-22.09%)
Mutual labels:  deployment
Deployr
A simple golang application to automate the deployment of software releases.
Stars: ✭ 282 (-15.82%)
Mutual labels:  deployment
Cloudbreak
A tool for provisioning and managing Apache Hadoop clusters in the cloud. Cloudbreak, as part of the Hortonworks Data Platform, makes it easy to provision, configure and elastically grow HDP clusters on cloud infrastructure. Cloudbreak can be used to provision Hadoop across cloud infrastructure providers including AWS, Azure, GCP and OpenStack.
Stars: ✭ 301 (-10.15%)
Mutual labels:  deployment
Rocketeer
Send your projects up in the clouds
Stars: ✭ 2,710 (+708.96%)
Mutual labels:  deployment
Trampoline
Admin Spring Boot Locally
Stars: ✭ 325 (-2.99%)
Mutual labels:  deployment
Applikatoni
🍕 A self-hosted deployment server for your team
Stars: ✭ 296 (-11.64%)
Mutual labels:  deployment
Adapt
ReactJS for your infrastructure. Create and deploy full-stack apps to any infrastructure using the power of React.
Stars: ✭ 317 (-5.37%)
Mutual labels:  deployment
Gitee Pages Action
🤖 Auto Deploy Gitee Pages | 无须人为干预,自动部署 Gitee Pages
Stars: ✭ 265 (-20.9%)
Mutual labels:  deployment
Antdeploy
Tools to deploy applications to remote server(iis,windowsService,linuxService,docker) support netframwork and dotnetcore,support rollback and increment deploy
Stars: ✭ 279 (-16.72%)
Mutual labels:  deployment
Morph
NixOS deployment tool
Stars: ✭ 303 (-9.55%)
Mutual labels:  deployment
Harp
A Go application deployment tool.
Stars: ✭ 263 (-21.49%)
Mutual labels:  deployment
Kubernetes Digitalocean Terraform
📋 🌊 🌎 Setup a simple Kubernetes cluster in Digital Ocean using Terraform
Stars: ✭ 324 (-3.28%)
Mutual labels:  deployment
Tomo
A friendly CLI for deploying Rails apps ✨
Stars: ✭ 260 (-22.39%)
Mutual labels:  deployment
Shineupdater
An Enterprise app update framework for iOS
Stars: ✭ 301 (-10.15%)
Mutual labels:  deployment
Linuxdeploy
Install and run GNU/Linux on Android
Stars: ✭ 3,775 (+1026.87%)
Mutual labels:  deployment
Template Building Blocks
A tool for deploying Azure infrastructure based on proven practices. Azure building blocks take advantage of the Azure CLI and Azure Resource Manager templates to provision collections of resources as logical units with production-ready settings.
Stars: ✭ 325 (-2.99%)
Mutual labels:  deployment
Vue Cli Plugin S3 Deploy
A vue-cli plugin that uploads your built Vue.js project to an S3 bucket
Stars: ✭ 304 (-9.25%)
Mutual labels:  deployment

mix docker

🚨🚨 This project is now obsolete and abandoned! 🚨🚨

With docker multi-stage builds you can simply use:

# Dockerfile
FROM elixir:1.6.5-alpine as build

# install build dependencies
RUN apk add --update git

# prepare build dir
RUN mkdir /app
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# set build ENV
ENV MIX_ENV=prod

# install mix dependencies
COPY mix.exs mix.lock ./
COPY config ./
COPY deps ./
RUN mix deps.compile

# build release
COPY . .
RUN mix release --no-tar --verbose

# prepare release image
FROM alpine:3.6
RUN apk add --update bash openssl

RUN mkdir /app && chown -R nobody: /app
WORKDIR /app
USER nobody

COPY --from=build /app/_build/prod/rel/myapp ./

ENV REPLACE_OS_VARS=true
ENV HTTP_PORT=4000 BEAM_PORT=14000 ERL_EPMD_PORT=24000
EXPOSE $HTTP_PORT $BEAM_PORT $ERL_EPMD_PORT

ENTRYPOINT ["/app/bin/myapp"]

and standard docker build.

OLD README CONTENT

Build Status

Put your Elixir app inside minimal Docker image. Based on alpine linux and distillery releases.

Installation

  1. Add mix_docker to your list of dependencies in mix.exs:
def deps do
  [{:mix_docker, "~> 0.5.0"}]
end
  1. Configure Docker image name
# config/config.exs
config :mix_docker, image: "recruitee/hello"
  1. Run mix docker.init to init distillery release configuration

  2. Run mix docker.build & mix docker.release to build the image. See Usage for more.

Guides

Usage

Build a release

Run mix docker.build to build a release inside docker container

Create minimal run container

Run mix docker.release to put the release inside minimal docker image

Publish to docker registry

Run mix docker.publish to push newly created image to docker registry

All three in one pass

Run mix docker.shipit

Customize default Dockerfiles

Run mix docker.customize

FAQ

How to configure my app?

Using ENV variables. The provided Docker images contain REPLACE_OS_VARS=true, so you can use "${VAR_NAME}" syntax in config/prod.exs like this:

config :hello, Hello.Endpoint,
  server: true,
  url: [host: "${DOMAIN}"]

config :hello, Hello.Mailer,
  adapter: Bamboo.MailgunAdapter,
  api_key: "${MAILGUN_API_KEY}"

How to configure the image tag?

By default, the image tag uses the following format: {mix-version}.{git-count}-{git-sha} You can provide your own tag template in config/prod.exs like this:

# config/config.exs
config :mix_docker,
  tag: "dev_{mix-version}_{git-sha}"

Additionally, you can pass the tag as an argument to mix docker.publish and mix docker.shipit:

mix docker.publish --tag "{mix-version}-{git-branch}"

See below for a list of possible variables

Variable Description
{mix-version} Current project version from mix.exs
{rel-version} Default distillery release version
{git-sha} Git commit SHA (10 characters)
{git-shaN} Git commit SHA (N characters)
{git-count} Git commit count
{git-branch} Git branch

What version of Erlang/Elixir is installed by default?

The default dockerfiles are based on bitwalker/alpine-erlang and elixir installed from apk repository

The following table summarizes the default versions:

mix_docker version alpine erlang elixir
up to 0.3.2 3.4 18.3 [email protected] at the time of build
0.4.0 3.5 19.2 [email protected]=1.4.1-r0
0.4.1 3.5 19.2 [email protected]=1.4.2-r0

Please note that you can use any version you want by customizing your dockerfiles. See mix docker.customize for reference.

How to attach to running app using remote_console?

The easiest way is to docker exec into running container and run the following command, where CID is the app container IO and hello is the name of your app.

docker exec -it CID /opt/app/bin/hello remote_console

Using alternative Dockerfiles

How to install additional packages into build/release image?

First, run mix docker.customize to copy Dockerfile.build and Dockerfile.release into your project directory. Now you can add whatever you like using standard Dockerfile commands. Feel free to add some more apk packages or run some custom commands. TIP: To keep the build process efficient check whether a given package is required only for compilation (build) or runtime (release) or both.

How to move the Dockerfiles?

You can specify where to find the two Dockerfiles in the config.

# config/config.exs
config :mix_docker,
  dockerfile_build: "path/to/Dockerfile.build",
  dockerfile_release: "path/to/Dockerfile.release"

The path is relative to the project root, and the files must be located inside the root.

How to configure an Umbrella app?

The default build Dockerfile does not handle the installation of umbrella app deps, so you will need to modify it to match the structure of your project.

Run mix docker.customize and then edit Dockerfile.build to copy across each of your umbrella's applications.

COPY mix.exs mix.lock ./

RUN mkdir -p apps/my_first_app/config
COPY apps/my_first_app/mix.exs apps/my_first_app/
COPY apps/my_first_app/config/* apps/my_first_app/config/

RUN mkdir -p apps/my_second_app/config
COPY apps/my_second_app/mix.exs apps/my_second_app/
COPY apps/my_second_app/config/* apps/my_second_app/config/

# etc.

How to configure a Phoenix app?

To run a Phoenix app you'll need to install additional packages into the build image: run mix docker.customize.

Modify the apk --no-cache --update add command in the Dockerfile.build as follows (add nodejs and python):

# Install Elixir and basic build dependencies
RUN \
    echo "@edge http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
    apk update && \
    apk --no-cache --update add \
      git make g++ \
      nodejs python \
      [email protected] && \
    rm -rf /var/cache/apk/*

Install nodejs dependencies and cache them by adding the following lines before the COPY command:

# Cache node deps
COPY package.json ./
RUN npm install

Build and digest static assets by adding the following lines after the COPY command:

RUN ./node_modules/brunch/bin/brunch b -p && \
    mix phoenix.digest

Add the following directories to .dockerignore:

node_modules
priv/static

Remove config/prod.secret.exs file and remove a reference to it from config/prod.exs. Configure your app's secrets directly in config/prod.exs using the environment variables.

Make sure to add server: true to your app's Endpoint config.

Build the images and run the release image normally.

Check out this post for detailed walkthrough of the Phoenix app configuration.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].