aprs.me/Dockerfile
Graham McIntire 7e4bbbaff5
Fix deployment timestamp always showing 'less than a minute ago' in k8s
Previously, the deployment timestamp was set to DateTime.utc_now() when
the application started, which meant it would always show as recent in
k8s environments where pods are recreated on each deployment.

This commit:
- Updates Release.init() to check for DEPLOYED_AT environment variable
- Falls back to current time if env var is not set (backwards compatible)
- Adds proper ISO8601 timestamp parsing with error handling
- Updates GitHub Actions deploy workflow to set DEPLOYED_AT during deployment
- Creates k8s patch file for future manual deployments

The deployment timestamp will now persist across pod restarts in k8s,
showing the actual deployment time rather than pod startup time.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 12:06:12 -05:00

66 lines
No EOL
1.6 KiB
Docker

# Build arguments
ARG ELIXIR_VERSION=1.18.4
ARG OTP_VERSION=27.2.4
ARG DEBIAN_VERSION=bullseye-20250520-slim
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
# Build stage
FROM ${BUILDER_IMAGE} AS builder
# Install build dependencies
RUN apt-get update -y && \
apt-get install -y --no-install-recommends gcc g++ make git && \
apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
ENV MIX_ENV=prod
# Install mix dependencies
COPY mix.exs mix.lock ./
COPY vendor vendor
RUN mix deps.get --only $MIX_ENV && \
mix deps.compile
# Copy and compile application
COPY config config
COPY lib lib
COPY assets assets
COPY priv priv
COPY rel rel
# Build application
RUN cd vendor/aprs && mix compile && cd ../.. && \
mkdir -p _build/prod/lib/aprs/ebin && \
cp -r vendor/aprs/_build/prod/lib/aprs/ebin/* _build/prod/lib/aprs/ebin/ && \
mix compile && \
mix assets.deploy && \
mix release
# Runtime stage
FROM ${RUNNER_IMAGE}
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
libstdc++6 openssl libncurses5 locales ca-certificates && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
useradd -r -u 1001 -g root -s /bin/false elixir
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
WORKDIR /app
# Ensure proper ownership
RUN chown -R elixir:root /app
COPY --from=builder --chown=elixir:root /app/_build/prod/rel/aprsme ./
USER elixir
CMD ["/app/bin/server"]