testing build and test

This commit is contained in:
2026-03-03 15:30:25 -07:00
parent 7eb95af0b8
commit 2746eadab7
11 changed files with 383 additions and 178 deletions

View File

@@ -1,39 +1,46 @@
# Git
# This file excludes paths from the Docker build context.
#
# By default, Docker's build context includes all files (and folders) in the
# current directory. Even if a file isn't copied into the container it is still sent to
# the Docker daemon.
#
# There are multiple reasons to exclude files from the build context:
#
# 1. Prevent nested folders from being copied into the container (ex: exclude
# /assets/node_modules when copying /assets)
# 2. Reduce the size of the build context and improve build time (ex. /build, /deps, /doc)
# 3. Avoid sending files containing sensitive information
#
# More information on using .dockerignore is available here:
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
.dockerignore
# Ignore git, but keep git HEAD and refs to access current commit hash if needed:
#
# $ cat .git/HEAD | awk '{print ".git/"$2}' | xargs cat
# d0b8727759e1e0e7aa3d41707d12376e373d5ecc
.git
.gitignore
!.git/HEAD
!.git/refs
# Common development/test artifacts
/cover/
/doc/
/test/
/tmp/
.elixir_ls
# Mix artifacts
/_build
/deps
/_build/
/deps/
*.ez
# Build artifacts
# Generated on crash by the VM
erl_crash.dump
# Static artifacts
/priv/static/
# Environment files
.env
.env.local
# Editor files
.vscode
.idea
*.swp
*.swo
*~
# OS files
.DS_Store
Thumbs.db
# Test files
/cover
/test
# Documentation
/doc
# Node modules (if any frontend code was in here)
node_modules
# Static artifacts - These should be fetched and built inside the Docker image
# https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Release.html#module-docker
/assets/node_modules/
/priv/static/assets/
/priv/static/cache_manifest.json

View File

@@ -1,39 +1,58 @@
FROM hexpm/elixir:1.15.7-erlang-26.1.2-alpine-3.18.4 AS build
ARG ELIXIR_VERSION=1.18.4
ARG OTP_VERSION=27.3.4.8
ARG DEBIAN_VERSION=trixie-20260223-slim
ARG BUILDER_IMAGE="docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential git \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache build-base git
WORKDIR /app
RUN mix local.hex --force && \
mix local.rebar --force
ENV MIX_ENV=prod
RUN mix local.hex --force \
&& mix local.rebar --force
ENV MIX_ENV="prod"
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile
COPY lib lib
RUN mix compile
COPY config/runtime.exs config/
COPY priv priv
COPY lib lib
RUN mix compile
COPY config/runtime.exs config/
RUN mix release
FROM alpine:3.18.4 AS app
FROM ${RUNNER_IMAGE} AS final
RUN apk add --no-cache libstdc++ openssl ncurses-libs bash
ENV USER="elixir"
WORKDIR /app
RUN addgroup -g 1000 $USER && \
adduser -D -u 1000 -G $USER $USER
RUN apt-get update \
&& apt-get install -y --no-install-recommends libstdc++6 openssl libncurses6 locales ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build --chown=elixir:elixir /app/_build/prod/rel/backend ./
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
&& locale-gen
USER elixir
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
WORKDIR "/app"
RUN chown nobody /app
ENV MIX_ENV="prod"
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/backend ./
USER nobody
ENV HOME=/app
ENV MIX_ENV=prod
ENV PHX_SERVER=true
EXPOSE 4000 4369 9000-9100
CMD ["/app/bin/backend", "start"]

View File

@@ -1,4 +1,4 @@
FROM hexpm/elixir:1.15.7-erlang-26.1.2-alpine-3.18.4
FROM hexpm/elixir:1.18.0-rc.0-erlang-26.2.5.8-alpine-3.23.3
RUN apk add --no-cache build-base git bash wget
WORKDIR /app