Hey there!
I'm working on putting together my dev flow for my elixir application and I think I'm really close to something I'm happy with but I have a lingering issue with how to run various gen tasks.
For example, I want to generate a new ecto migration for my application so I run docker-compose exec api mix ecto.gen.migration test_migration and it creates the migration file. Great! Because, I have my volume defined in my docker-compose.yml, I see the migration file on my host machine.
But when I go to edit the migration file, I get a permission denied error because the owner was set to root by docker/docker-compose. So that's a problem...
Here's my docker file and my docker-compose.yml:
FROM elixir:1.14
EXPOSE 4000
RUN apt-get update && \
apt-get install -y postgresql-client && \
apt-get install -y inotify-tools
WORKDIR /app
RUN mix local.hex --force && mix local.rebar --force
version: '3.5'
services:
api:
build:
context: .
dockerfile: ./api/Dockerfile
environment:
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: sbt_dev
PGHOST: db
PGPORT: 5432
ports:
- "4000:4000"
restart: unless-stopped
depends_on:
- db
volumes:
- ./api/config:/app/config
- ./api/lib:/app/lib
- ./api/priv:/app/priv
- ./api/test:/app/test
- ./api/dev.sh:/app/dev.sh
- ./api/mix.exs:/app/mix.exs
- ./api/mix.lock:/app/mix.lock
- ./api/.formatter.exs:/app/.formatter.exs
command:
- "./dev.sh"
db:
image: postgres:13.7
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
restart: unless-stopped
Anyone have any good ideas? Or alternate workflows? Ideally, I'd love to be able to use the gen mix tasks without having to have elixir installed on the host machine.