Permalink
Browse files

Adds a development Docker Compose setup for local dev

To use Docker Compose for local development, copy env.template to .env
and add a Slack API token. To run Cog use the command:

    docker-compose run -f docker-compose.dev.yml up
  • Loading branch information...
davejlong committed Feb 15, 2018
1 parent 8099c26 commit 0541dc98ad36a241e5eff49843c808805748d731
Showing with 90 additions and 0 deletions.
  1. +38 −0 Dockerfile.dev
  2. +51 −0 docker-compose.dev.yml
  3. +1 −0 env.template
View
@@ -0,0 +1,38 @@
FROM elixir:1.3-slim
# ENV MIX_ENV prod
RUN addgroup --gid 60000 cogbot && \
adduser --home /home/cogbot --uid 60000 --gid 60000 --gecos cogbot \
--shell /bin/bash --disabled-password cogbot
# Create directories and upload cog source
WORKDIR /home/cogbot/cog
# Really, we only need the cog directory to be owned by cogbot,
# because (by default) that's where we write log files. None of the
# actual scripts or library files need to be owned by cogbot.
RUN chown -R cogbot /home/cogbot/cog
RUN apt-get update && \
apt-get -yqq install build-essential git libexpat1-dev && \
rm -rf /var/lib/apt/lists/* && \
mix do local.hex --force, local.rebar --force
COPY mix.exs mix.lock /home/cogbot/cog/
COPY config/ /home/cogbot/cog/config/
RUN mix do deps.get --no-archives-check, deps.compile
COPY . /home/cogbot/cog
RUN mix compile --no-deps-check --no-archives-check
# This should be in place in the build environment already
COPY cogctl-for-docker-build /usr/local/bin/cogctl
USER cogbot
# TODO: For some reason, Hex needs to be present in the cogbot
# user's home directory for Cog to run (specifically, for it to apply
# the database migrations at startup). It complains of not being able
# to build gen_stage, *even though it's already been built!*
RUN mix local.hex --force
View
@@ -0,0 +1,51 @@
version: '2'
services:
postgres:
image: postgres:9.5
environment:
- POSTGRES_USER=cog
- POSTGRES_PASSWORD=cog
cog:
build: .
environment:
- COG_API_URL_BASE=http://cog:4000
- COG_TRIGGER_URL_BASE=http://cog:4001
- COG_SERVICE_URL_BASE=http://cog:4002
- COG_MQTT_HOST=0.0.0.0
- DATABASE_URL=ecto://cog:cog@postgres:5432/cog
- COG_SLACK_ENABLED=1
- SLACK_API_TOKEN=${SLACK_API_TOKEN}
- COG_BOOTSTRAP_USERNAME=admin
- COG_BOOTSTRAP_PASSWORD=changeme
- COG_BOOTSTRAP_EMAIL_ADDRESS=cog@localhost
- COG_BOOTSTRAP_FIRST_NAME=Cog
- COG_BOOTSTRAP_LAST_NAME=Administrator
- COG_ALLOW_SELF_REGISTRATION=true
- RELAY_ID=00000000-0000-0000-0000-000000000000
- RELAY_COG_TOKEN=supersecret
depends_on:
- postgres
ports:
- 1883
- 4000:4000
- 4001:4001
- 4002:4002
entrypoint: /home/operable/cog/scripts/docker-start
relay:
image: operable/relay:latest
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- COG_API_URL_BASE=http://cog:4000
- COG_TRIGGER_URL_BASE=http://cog:4001
- COG_SERVICE_URL_BASE=http://cog:4002
- RELAY_COG_REFRESH_INTERVAL=30s
- RELAY_DOCKER_CLEAN_INTERVAL=1m
- RELAY_COG_HOST=cog
- RELAY_DYNAMIC_CONFIG_ROOT=/tmp/bundle_configs
- RELAY_ID=00000000-0000-0000-0000-000000000000
- RELAY_COG_TOKEN=supersecret
depends_on:
- cog
entrypoint: /usr/local/bin/relay
View
@@ -0,0 +1 @@
SLACK_API_TOKEN=

0 comments on commit 0541dc9

Please sign in to comment.