Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cao7113 committed Jun 29, 2024
1 parent dc2e99b commit abc8282
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 56 deletions.
109 changes: 56 additions & 53 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN mix local.hex --force && \
# set build ENV
ENV MIX_ENV="prod"


# todoooo
RUN ls -al
RUN which git
RUN ls -al .git || true
Expand All @@ -44,63 +44,66 @@ COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
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 config config
RUN mix commit
RUN mix deps.compile

COPY priv priv
COPY lib lib
COPY assets assets
# compile assets
RUN mix assets.deploy

# Compile the release
RUN mix compile

# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/

COPY rel rel
RUN mix release
# iex helpers
COPY .iex.exs _build/${MIX_ENV}/rel/hello_phx/bin

# start a new build stage so that the final image will only contain
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}

RUN apt-get update -y && \
apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
RUN mkdir -p .git/refs/heads
COPY .git/refs/heads/main .git/refs/heads
RUN ls -al .git/refs/heads

# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
# # 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 config config
# RUN mix deps.compile

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# COPY priv priv
# COPY lib lib
# COPY assets assets
# # compile assets
# RUN mix assets.deploy

WORKDIR "/app"
RUN chown nobody /app
# # Compile the release
# RUN mix compile

# set runner ENV
ENV MIX_ENV="prod"
# Appended by flyctl https://fly.io/docs/elixir/getting-started/#important-ipv6-settings
ENV ECTO_IPV6 true
ENV ERL_AFLAGS "-proto_dist inet6_tcp"
# # Changes to config/runtime.exs don't require recompiling the code
# COPY config/runtime.exs config/

# COPY rel rel
# RUN mix release
# # iex helpers
# COPY .iex.exs _build/${MIX_ENV}/rel/hello_phx/bin

# # start a new build stage so that the final image will only contain
# # the compiled release and other runtime necessities
# FROM ${RUNNER_IMAGE}

# RUN apt-get update -y && \
# apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
# && apt-get clean && rm -f /var/lib/apt/lists/*_*

# # Set the locale
# RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen

# ENV LANG en_US.UTF-8
# ENV LANGUAGE en_US:en
# ENV LC_ALL en_US.UTF-8

# WORKDIR "/app"
# RUN chown nobody /app

# # set runner ENV
# ENV MIX_ENV="prod"
# # Appended by flyctl https://fly.io/docs/elixir/getting-started/#important-ipv6-settings
# ENV ECTO_IPV6 true
# ENV ERL_AFLAGS "-proto_dist inet6_tcp"

# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/hello_phx ./
# # Only copy the final release from the build stage
# COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/hello_phx ./

USER nobody
# USER nobody

# If using an environment that doesn't automatically reap zombie processes, it is
# advised to add an init process such as tini via `apt-get install`
# above and adding an entrypoint. See https://github.com/krallin/tini for details
# ENTRYPOINT ["/tini", "--"]
# # If using an environment that doesn't automatically reap zombie processes, it is
# # advised to add an init process such as tini via `apt-get install`
# # above and adding an entrypoint. See https://github.com/krallin/tini for details
# # ENTRYPOINT ["/tini", "--"]

CMD ["/app/bin/server"]
# CMD ["/app/bin/server"]
6 changes: 3 additions & 3 deletions config/commit.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ defmodule GitCommit do
git log -1 origin/main --format="%H %cd" --date=local
"""

@git_branch "main"
@head_file ".git/refs/heads/#{@git_branch}"

def latest do
[
&from_cmd/0,
Expand Down Expand Up @@ -38,6 +35,9 @@ defmodule GitCommit do
end
end

@git_branch "main"
@head_file ".git/refs/heads/#{@git_branch}"

def from_file(head_file \\ @head_file) do
if File.exists?(head_file) do
{
Expand Down

0 comments on commit abc8282

Please sign in to comment.