Skip to content

Instantly share code, notes, and snippets.

@brainlid
Created July 3, 2018 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brainlid/d5147116322ff01c6ce4c716c99caeac to your computer and use it in GitHub Desktop.
Save brainlid/d5147116322ff01c6ce4c716c99caeac to your computer and use it in GitHub Desktop.
Describe solution for user ownership of files
docker-compose build --build-arg DEV_USER=`id -u` my_project
FROM elixir:1.6.5-alpine
ARG DEV_USER=1000
RUN apk add --no-cache \
# bash terminal Support
bash \
# development - could be separated/virtual for removal, but lets just get the bin going -BJG
inotify-tools wget curl smem tar gcc g++ libc-dev libffi-dev make \
# utilities
bzip2 unzip xz git \
# bring in elixir
elixir erlang-crypto erlang-inets erlang-xmerl erlang-syntax-tools \
erlang-parsetools erlang-runtime-tools erlang-tools erlang-dev \
# postgres
postgresql-client \
# NodeJS for compiling assets
nodejs
# Expose port 5000 to the Docker host, so we can access it
# from the outside.
EXPOSE 5000
# Setup the assets directory and install the packages
RUN mkdir -p /app/assets
WORKDIR /app/assets
COPY assets/package.json assets/package-lock.json ./
# Create a user and group that has the same uid as the user running the host container
RUN addgroup -g ${DEV_USER} -S dev_user && \
adduser -u ${DEV_USER} -S dev_user -G dev_user
# Activate the new user
USER ${DEV_USER}
# hex and rebar
RUN mix local.hex --force && \
mix local.rebar --force
# Install the Phoenix framework itself
RUN mix archive.install --force https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez
WORKDIR /app
CMD ["mix", "do", "deps.get", "deps.compile", "compile", "ecto.migrate", "phx.server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment