Create a gist now

Instantly share code, notes, and snippets.

@mjason /Dockerfile
Last active May 16, 2017

What would you like to do?
build phoenix in docker
#!/usr/bin/env bash
echo "build start"
cd /var/app
if [ ! -d "./demo" ]; then
echo "clone code"
git clone git@github.com:mjason/demo.git
else
echo "pull code"
cd /var/app/demo
git fetch --all
git reset --hard origin/master
fi
cd /var/app/demo
cp ../config/prod.secret.exs ./config/prod.secret.exs
mix local.hex --force
mix deps.get
yarn
npm run deploy
mix local.rebar --force
MIX_ENV=prod mix do compile, phoenix.digest, release --env=prod
[Unit]
Description=demo
After=network.target
[Service]
User=root
WorkingDirectory=/opt/app/demo
ExecStart=/opt/app/demo/bin/demo start
ExecStop=/opt/app/demo/bin/demo stop
Environment=PORT=8080
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
#!/usr/bin/env bash
rsync -r --progress /var/app/demo/_build/prod/rel/demo ubuntu@you_hosts:/opt/app
ssh ubuntu@you_hosts 'sudo service demo restart'
version: '2'
services:
build:
build: '.'
volumes:
- ./_src:/var/app
- ./config/prod.secret.exs:/var/app/config/prod.secret.exs
- $HOME/.ssh/id_rsa:/root/.ssh/id_rsa
- ./build.sh:/bin/build
- ./deploy.sh:/bin/deploy
command: build
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y git wget curl build-essential
RUN wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && dpkg -i erlang-solutions_1.0_all.deb
RUN apt-get update
RUN apt-get install erlang -y
RUN apt-get install -y elixir
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install yarn
RUN apt-get install software-properties-common -y
RUN apt-add-repository ppa:ansible/ansible
RUN apt-get update
RUN apt-get install ansible -y
RUN apt-get install -y --no-install-recommends locales
RUN apt-get update && apt-get install -y --no-install-recommends \
locales \
&& export LANG=en_US.UTF-8 \
&& echo $LANG UTF-8 > /etc/locale.gen \
&& locale-gen \
&& update-locale LANG=$LANG \
&& rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
LC_ALL=en_US.UTF-8
RUN mkdir -p /root/.ssh
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
RUN echo "Host site_host\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
WORKDIR /var/app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment