From abc82821b213288715b27fdcec14f3007b0a19d6 Mon Sep 17 00:00:00 2001 From: Ryn Cao Date: Sat, 29 Jun 2024 17:53:52 +0800 Subject: [PATCH] fix --- Dockerfile | 109 ++++++++++++++++++++++++---------------------- config/commit.exs | 6 +-- 2 files changed, 59 insertions(+), 56 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5a86557..0508a68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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"] diff --git a/config/commit.exs b/config/commit.exs index 32fa251..b7cc06e 100644 --- a/config/commit.exs +++ b/config/commit.exs @@ -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, @@ -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 {