JovaniPink

JovaniPink

I just saw the announce of Awesome-Compose, “a Github repository with application samples” using Docker Compose.

Announcement Blog:
Awesome Compose for Sample Apps

Actual Git Repo:
Awesome-Compose

I thought it would be a great community effort if we added solid, regularly used, and popular docker compose recipes to the list.

Could you’all send me links or guides me to any examples that the community uses so we could add.

Thank you and for your support!

PS: I’m just starting off with Elixir and Phoenix and this would be super beneficial for me. :slight_smile:

Showing Posts 1 to 10

gregvaughn

gregvaughn

In contrast I am quite comfortable with Elixir and Phoenix but I’m a novice at Docker. My main impression comes from all the people having problems with it. Knowing that solid recipes exist would be a huge benefit.

nayibor

nayibor

version: "3"
services:
  web:
    image: erlang:22.3
    ports:
      - "8080:8080" 
      - "8006:8006"
    volumes:
      - "./:/opt/erlang/app"
    stdin_open: true
    tty: true
  mysql_db:
    image: mysql:latest
    environment:
      MYSQL_ROOT_PASSWORD: "app"
      MYSQL_DATABASE: "app"
      MYSQL_USER: "app"
      MYSQL_PASSWORD: "app"
    volumes:
      - "../app_db_db_scripts/latest.sql:/docker-entrypoint-initdb.d/app.sql"
    ports:
      - "3309:3306"
  rabbit:
    image: rabbitmq:latest
    hostname: rabbit
    environment:
      RABBITMQ_ERLANG_COOKIE: "app"
  node:
    image: node:latest
    ports:
      - "8000:8000"
      - "3001:3001"
      - "3000:3000"
    volumes:
      - "../../../app/:/opt/erlang/app"
      - "/tmp/.X11-unix:/tmp/.X11-unix"
    stdin_open: true
    tty: true
  editor:
    image: swaggerapi/swagger-editor:latest
    ports:
      - "8001:8080"
    stdin_open: true
    tty: true

above is a compose file i used for an erlang web application
so the compose file had sections for
erlang -for the web application(one port for application and one for edoc html files)
mysql -for the database
rabbitmq - for rabbitmq server
node - was using zurb framework for frontend so needed a nodejs image
swagger -for the api editor

below is also a simpler one for elixir which i have used before

version: "3"
services:
  web:
    image: elixir:1.7.4
    ports:
      - "4000:4000"
    volumes:
      - "./:/opt/elixir/elixir"
    stdin_open: true
    tty: true
  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: example
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
    ports:
      - "5433:5432"
JovaniPink

JovaniPink OP

Thank you sharing.

JovaniPink

JovaniPink OP

Great work and thank you for taking the initiative. I found a couple of Elixir-Phoenix-Postgres docker-compose out in the wild … https://github.com/nicbet/docker-phoenix, https://binarynoggin.com/deploying-phoenix-with-circleci/, and of what @nayibor added up top and to your pull request.

I appreciate it.

axelclark

axelclark

I have a docker-compose.yml file in a blog post I wrote:

https://axelclark.com/deploy-phoenix-to-digital-ocean/#build-release-with-docker

JackMaarek

JackMaarek

I have one docker-compose.yml file that build the phoenix container for backend and a elm app container for front-end:

You can access the repo here : GitHub - HETIC-MT-P2021/aio-group3-proj01: Elm application with Phoenix API on Docker : Edwin Vautier - Jack Maarek - Jason Gauvin · GitHub

Here is the docker-compose.yml:

version: '3.7'

services:
  db:
    image: postgres:9.6
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      PGDATA: /var/lib/postgresql/data/pgdata
    restart: always
    volumes:
      - ./pgdata:/var/lib/postgresql/data
  phoenix:
    build: .docker/backend/.
    volumes:
    - ./source/backend/api_app:/backend
    - .docker/backend/phoenix-setup.sh:/phoenix-setup.sh
    command: ../phoenix-setup.sh
    environment:
      PGUSER: postgres
      PGPASSWORD: postgres
      PGDATABASE: database_name
      PGPORT: 5432
      PGHOST: db
    ports:
      - 4000:4000
    depends_on:
      - db
  elm-app:
    build: .docker/frontend/.
    volumes:
      - ./source/frontend/:/elm-app
    command: elm reactor
    ports:
      - 8000:8000
    depends_on:
      - phoenix
volumes:
  pgdata:

The Docker file for backend api:

FROM elixir:latest

LABEL maintainer="Edouin Vautier, Jason Gauvin, Jack Maarek <https://github.com/HETIC-MT-P2021/aio-group3-proj01>"


RUN mix local.hex --force &&\
    mix local.rebar --force &&\
    mix archive.install hex phx_new 1.4.16 --force

RUN apt-get update && \
  ## install inotify-tool for phoenix hot reload
  apt-get install -y inotify-tools && \
  # Install postgres client
  apt-get install -y postgresql-client && \
  # Clear apt cache
   rm -rf /var/lib/apt/lists/*

WORKDIR /backend

EXPOSE 4000

with a setup shell file :

#!/usr/bin/env bash

mix deps.get # install project depencies
mix ecto.create
mix ecto.migrate  
exec mix phx.server

And the dockerfile for frontend:

FROM alpine:latest

RUN mkdir /elm-app
WORKDIR /elm-app

# Install curl package
RUN apk update && apk add --update curl && apk add --update nodejs npm && \
    # Install elm
    curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz && \
    gunzip elm.gz && \
    chmod +x elm && \
    mv elm /usr/local/bin/

EXPOSE 8000
JovaniPink

JovaniPink OP

Sweet Work.

akoutmos

akoutmos

Author of Build a Weather Station with Elixir and Nerves

I leverage Docker Compose for most of my tutorials on my blog. Below is a listing of the tech stacks, articles, and repos for each of the tutorials:

Prometheus, PostGIS and Phoenix Part 1
Article: Prometheus, PostGIS and Phoenix Part 1-Alex Koutmos | Engineering Blog
Repo: GitHub - akoutmos/elixir_monitoring_prom: Companion code for https://akoutmos.com/post/prometheus-postgis-and-phoenix/ · GitHub
Tech Stack: Elixir app, Postgres+PostGIS, Grafana, Prometheus, Postgres Exporter

Broadway, RabbitMQ, and the Rise of Elixir Part 1
Article: Broadway, RabbitMQ, and the Rise of Elixir Part 1-Alex Koutmos | Engineering Blog
Repo: GitHub - akoutmos/elixir_popularity: Companion code for https://akoutmos.com/post/broadway-rabbitmq-and-the-rise-of-elixir/ · GitHub
Tech Stack: cAdvisor, RabbitMQ, Postgres, Postgres Exporter, Grafana, Prometheus

Structured logging in Elixir using Loki
Article: Structured logging in Elixir using Loki-Alex Koutmos | Engineering Blog
Repo: GitHub - akoutmos/auto_finder: Companion code for https://akoutmos.com/post/elixir-logging-loki/ · GitHub
Tech Stack: Elixir app, Postgres, Loki, Grafana

And finally, while not Docker Compose specific, how to build Mix Releases with Docker:

Multi-stage Docker Builds and Elixir 1.9 Releases
Article: Multi-stage Docker Builds and Elixir 1.9 Releases-Alex Koutmos | Engineering Blog
Repo: GitHub - akoutmos/docker_elixir_19_release: Companion code for https://akoutmos.com/post/multipart-docker-and-elixir-1.9-releases/ · GitHub

JackMaarek

JackMaarek

Ok guys so I found that when you use volumes in docker-compose your create some side effects that could result in problems.

When you use the volume and pull everything from your project root directory you are overloading the content of the compiled stuff in your container so some dependencies won’t be “accessible” as their dependencies need to be compiled in order to work correctly.

Off course correct me if i’m wrong.

From my initial post I had a .docker folder that contains the necessary Dockerfile for my image with a setup shell script and in my project root directory I had my docker-compose file that was pulling all the project and target the project folder in my container.

Now I moved out my dockerfile in my project root directory because I canot copy files from a parent path of the context and even if it’s logic I do not really get how to keep my dockerfile in the docker folder, this is not much but I was usually using volumes in my compose files also to pull the source code even after a change. I’m also a little bit confused because this mean that at every change you need to rebuild the project, that’s a time waste.

At least you could only copy your mix.deps files and compile them but if you’re still using volumes you will override the deps and _build folder. For now I’m staying with this approach but do not hesitate to share your reviews !

The almighty @NobbZ explained very well all the side effects that this would cause and how a container should really behave: here.

Thanks a lot man !

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews