Skip to content

Instantly share code, notes, and snippets.

@mraaroncruz
Created October 29, 2020 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mraaroncruz/2fdab8916ddffd41deceeb6d919cdd75 to your computer and use it in GitHub Desktop.
Save mraaroncruz/2fdab8916ddffd41deceeb6d919cdd75 to your computer and use it in GitHub Desktop.
webkoll docker implementation (ugly)
FROM elixir:latest
RUN apt-get update && \
apt-get install -y python rsync
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& curl -sS 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 update \
&& apt install -y nodejs yarn
ENV APP_HOME /home/app
RUN useradd -m app \
&& mkdir -p ${APP_HOME} \
&& chown -R app:app ${APP_HOME}
USER app
WORKDIR ${APP_HOME}
ENV NPM_CONFIG_PREFIX=/home/app/.npm-global
ENV PATH=$PATH:/home/app/.npm-global/bin
CMD npm i -g yarn node-sass
# Build assets
COPY ./mix.exs ./
ENV MIX_ENV prod
ENV SECRET_KEY_BASE this_is_not_a_good_secret
ENV PORT 4000
# Install hex package manager
RUN mix local.hex --force \
&& mix local.rebar --force
# Install dependencies
RUN mix deps.get --only prod
COPY --chown=app:app ./assets ./assets
COPY --chown=app:app ./config ./config
USER app
RUN mkdir -p priv/static/css priv/static/fonts priv/static/images priv/static/js \
&& cat assets/static/js/webbkoll-*.js > priv/static/js/webbkoll.js \
&& rsync -av assets/static/* priv/static \
&& touch config/dev.secret.exs \
&& touch config/prod.secret.exs
# Build assets
# COPY --chown=app:app ./assets/package.json ./assets/yarn.lock ./assets/
RUN cd ./assets && yarn install
# Handle Elixir dependencies
COPY --chown=app:app ./mix.exs ./mix.lock ./
RUN mix do deps.get, deps.compile
# Copy rest of files over
COPY --chown=app:app . .
# Compile the project
RUN mix do compile, phx.digest
EXPOSE 4000
CMD ["/bin/bash", "-lc", "mix phx.server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment