Created
July 2, 2019 11:00
-
-
Save 1player/765cec58bbda39d86df23b10cddc8c8b to your computer and use it in GitHub Desktop.
This file contains 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.8.2-alpine as builder | |
ENV MIX_ENV=prod \ | |
REPLACE_OS_VARS=true | |
# Install hex | |
RUN /usr/local/bin/mix local.hex --force && \ | |
/usr/local/bin/mix local.rebar --force && \ | |
/usr/local/bin/mix hex.info | |
# Install other build dependencies | |
RUN apk add --no-cache nodejs make g++ git yarn | |
## | |
COPY . /build | |
# Compile | |
WORKDIR /build | |
RUN mix do deps.get, deps.compile, compile | |
# Build assets | |
WORKDIR /build/apps/hive_api/assets | |
RUN yarn install --frozen-lockfile && yarn cache clean && yarn run build:prod | |
# Package and build release | |
WORKDIR /build | |
RUN mix phx.digest && \ | |
mix release --env=prod && \ | |
mkdir /app && \ | |
tar xzf _build/prod/rel/hive/releases/latest/hive.tar.gz -C /app | |
# Stage 2 | |
FROM alpine@sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6 | |
EXPOSE 80 | |
EXPOSE 4369 | |
EXPOSE 9001 | |
RUN apk add --no-cache bash openssl curl tini | |
COPY --from=builder /app /app | |
COPY ./docker/healthcheck.sh /app/ | |
# Create data dirs | |
RUN mkdir -p /app/data/hive | |
ENTRYPOINT [ "/sbin/tini", "--" ] | |
ENV REPLACE_OS_VARS true | |
CMD app/bin/hive migrate && app/bin/hive foreground | |
HEALTHCHECK --interval=30s --timeout=30s --start-period=15s --retries=3 CMD [ "/app/healthcheck.sh" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment