Created
October 29, 2020 10:03
-
-
Save mraaroncruz/2fdab8916ddffd41deceeb6d919cdd75 to your computer and use it in GitHub Desktop.
webkoll docker implementation (ugly)
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: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