- The container expect your local
user
hasuid:gid
set as1000
- so when you run a command the files generated are not root owned
- you can run any command like:
docker-compose run phx mix ecto.create
docker-compose run phx iex -S mix phx.server
docker-compose run phx mix phx.new . --app myproj
- then run the server with
docker-compose up
Last active
April 27, 2020 17:40
-
-
Save jalberto/fc3a6bce99c4904069eb37b49e06fac9 to your computer and use it in GitHub Desktop.
Elixir & Phoenix on Docker for development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.2" | |
services: | |
phx: | |
image: myproj:latest | |
build: . | |
volumes: | |
- type: bind | |
source: . | |
target: /app | |
ports: | |
- "4000:4000" | |
depends_on: | |
- db | |
command: mix phx.server | |
db: | |
image: postgres:9.6 | |
environment: | |
- POSTGRES_DB | |
- POSTGRES_USER | |
- POSTGRES_PASSWORD | |
- POSTGRES_HOST_AUTH_METHOD=trust | |
ports: | |
- "5432:5432" | |
volumes: | |
- pgvol:/var/lib/postgresql/data | |
# mailhog: | |
# image: mailhog/mailhog:latest | |
# ports: | |
# - "1025:1025" | |
# - "1080:1080" | |
# - "8025:8025" | |
volumes: | |
pgvol: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM elixir:1.10 | |
ENV \ | |
PHX_VER=1.5.1 \ | |
NODE_VER=12.x \ | |
APP=/app HOME=/app \ | |
PKGS="inotify-tools postgresql-client git" | |
RUN groupadd -g 1000 appuser \ | |
&& useradd -r -u 1000 -g appuser appuser \ | |
&& mkdir -p $APP \ | |
&& chown appuser:appuser $APP | |
RUN \ | |
curl -sL https://deb.nodesource.com/setup_$NODE_VER | bash - \ | |
&& curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ | |
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ | |
&& apt-get update -qq \ | |
&& apt-get install -qq $PKGS \ | |
&& apt-get install -qq nodejs yarn \ | |
&& apt-get clean \ | |
&& rm -r /var/lib/apt/lists /var/cache/apt/archives | |
USER appuser | |
WORKDIR $APP | |
RUN \ | |
mix local.hex --force \ | |
&& mix local.rebar --force \ | |
&& mix archive.install hex phx_new $PHX_VER --force | |
EXPOSE 4000 | |
CMD ["iex"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment