-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.test
More file actions
68 lines (52 loc) · 1.62 KB
/
Dockerfile.test
File metadata and controls
68 lines (52 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Dockerfile for running the test suite with Chromium for integration tests.
# Uses the same base image as the production Dockerfile.
#
# Usage:
# docker compose -f docker-compose.test.yml run --rm test
# docker compose -f docker-compose.test.yml run --rm test mix test test/tr_web/integration/
ARG ELIXIR_VERSION=1.19.5
ARG OTP_VERSION=28.3.2
ARG DEBIAN_VERSION=bookworm-20260202-slim
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE}
# Install build dependencies, Chromium, chromedriver, and Xvfb
RUN apt-get update -y && \
apt-get install -y \
build-essential \
git \
chromium \
chromium-driver \
xvfb \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
WORKDIR /app
# Install hex and rebar
RUN mix local.hex --force && \
mix local.rebar --force
ENV MIX_ENV=test
# Install dependencies first for better layer caching
COPY mix.exs mix.lock ./
RUN mix deps.get && mix deps.compile
# Copy the rest of the project
COPY config config
COPY lib lib
COPY priv priv
COPY test test
COPY assets assets
# Compile the project
RUN mix compile
# Entrypoint: start Xvfb and chromedriver, then run the given command
COPY <<'ENTRYPOINT_SCRIPT' /usr/local/bin/docker-entrypoint.sh
#!/bin/bash
set -e
# Start virtual framebuffer
Xvfb :99 -screen 0 1280x1024x24 &
export DISPLAY=:99
# Start chromedriver
chromedriver --port=9515 --whitelisted-ips="" &
# Wait briefly for services to be ready
sleep 1
exec "$@"
ENTRYPOINT_SCRIPT
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["mix", "test"]