-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Docker.alpine
alternative image
#1512
Draft
jjcarstens
wants to merge
1
commit into
main
Choose a base branch
from
alpine-image
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,120 @@ | ||||||
ARG ELIXIR_VERSION=1.17.2 | ||||||
ARG OTP_VERSION=27.0.1 | ||||||
ARG ALPINE=3.20.3 | ||||||
ARG NODE_VERSION=16.20.2 | ||||||
|
||||||
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-alpine-${ALPINE}" | ||||||
ARG RUNNER_IMAGE="alpine:${ALPINE}" | ||||||
|
||||||
### | ||||||
### First Stage - Fetch deps for building web assets | ||||||
### | ||||||
FROM ${BUILDER_IMAGE} as deps | ||||||
|
||||||
ENV MIX_ENV=prod | ||||||
|
||||||
RUN apk update && apk add --no-cache git | ||||||
RUN mix local.hex --force && mix local.rebar --force | ||||||
|
||||||
WORKDIR /build | ||||||
|
||||||
COPY mix.* ./ | ||||||
RUN mix deps.get --only $MIX_ENV | ||||||
|
||||||
|
||||||
### | ||||||
### Second Stage - Build web assets | ||||||
### | ||||||
FROM node:${NODE_VERSION} as assets | ||||||
|
||||||
RUN mkdir -p /priv/static | ||||||
|
||||||
WORKDIR /build | ||||||
|
||||||
COPY --from=deps /build/deps deps | ||||||
COPY assets assets | ||||||
|
||||||
WORKDIR /build/assets | ||||||
|
||||||
# RUN npm install -g [email protected] | ||||||
RUN npm ci && npm cache clean --force && npm run deploy | ||||||
|
||||||
|
||||||
### | ||||||
### Third Stage - Building the Release | ||||||
### | ||||||
FROM ${BUILDER_IMAGE} as build | ||||||
|
||||||
# install dependencies | ||||||
RUN apk update && apk add --no-cache build-base git ca-certificates curl gnupg | ||||||
# Is this cleanup still needed? | ||||||
# && apt-get clean && rm -f /var/lib/apt/lists/*_* | ||||||
|
||||||
WORKDIR /build | ||||||
|
||||||
ENV HEX_HTTP_TIMEOUT=20 | ||||||
|
||||||
RUN mix local.hex --force && \ | ||||||
mix local.rebar --force | ||||||
|
||||||
ENV MIX_ENV=prod | ||||||
ENV SECRET_KEY_BASE=nokey | ||||||
|
||||||
COPY mix.lock ./ | ||||||
|
||||||
RUN mkdir config | ||||||
|
||||||
# copy compile-time config files before we compile dependencies | ||||||
# to ensure any relevant config change will trigger the dependencies | ||||||
# to be re-compiled. | ||||||
COPY config/config.exs config/${MIX_ENV}.exs config/ | ||||||
|
||||||
COPY mix.exs . | ||||||
RUN mix deps.get --only $MIX_ENV | ||||||
|
||||||
RUN mix deps.compile | ||||||
|
||||||
COPY priv priv | ||||||
COPY lib lib | ||||||
|
||||||
COPY --from=assets /build/priv/static priv/static | ||||||
|
||||||
RUN mix compile | ||||||
RUN mix phx.digest | ||||||
RUN mix sentry.package_source_code | ||||||
|
||||||
COPY config/runtime.exs config/ | ||||||
|
||||||
COPY rel rel | ||||||
|
||||||
RUN mix release | ||||||
|
||||||
|
||||||
### | ||||||
### Last Stage - Setup the Runtime Environment | ||||||
### | ||||||
|
||||||
FROM ${RUNNER_IMAGE} AS app | ||||||
|
||||||
RUN apk update \ | ||||||
&& apk add --no-cache fwup openssl bash openssl curl jq xdelta3 \ | ||||||
zip unzip wget musl-locales musl-locales-lang libstdc++ | ||||||
# Is this needed? libncurses6 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is for something related to iex maybe... but I'm not sure. Seems fine to skip for now |
||||||
# Do we need to clean things? | ||||||
# && apt-get clean && rm -rf /var/lib/apt/lists/* | ||||||
Comment on lines
+103
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Nope, drop it! |
||||||
|
||||||
ENV LANG="en_US.UTF-8" | ||||||
ENV LANGUAGE="en_US:en" | ||||||
ENV LC_ALL="en_US.UTF-8" | ||||||
|
||||||
WORKDIR /app | ||||||
|
||||||
COPY --from=build /build/_build/prod/rel/nerves_hub ./ | ||||||
|
||||||
ENV HOME=/app | ||||||
ENV MIX_ENV=prod | ||||||
ENV SECRET_KEY_BASE=nokey | ||||||
ENV PORT=4000 | ||||||
|
||||||
ENTRYPOINT ["bin/nerves_hub"] | ||||||
CMD ["start"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, drop it!