-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
111 lines (84 loc) · 2.3 KB
/
Dockerfile
File metadata and controls
111 lines (84 loc) · 2.3 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Dockerfile for Singularity Edge
# Multi-stage build optimized for Elixir releases
ARG ELIXIR_VERSION=1.17.3
ARG ERLANG_VERSION=27.1.2
ARG ALPINE_VERSION=3.20.3
ARG CACHEBUST=3
# ====================================
# Stage 1: Build Dependencies
# ====================================
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION} AS deps
RUN apk add --no-cache \
git \
build-base \
rocksdb \
rocksdb-dev
WORKDIR /app
# Install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# Copy dependency files
COPY mix.exs mix.lock ./
RUN mix deps.get --only prod
# ====================================
# Stage 2: Build Assets
# ====================================
FROM deps AS assets
RUN apk add --no-cache nodejs npm
WORKDIR /app
# Cache-busting: force re-copy of assets
ARG CACHEBUST=3
RUN echo "Cache bust: $CACHEBUST"
# Copy assets
COPY assets assets/
COPY priv priv/
# Install and build assets
RUN cd assets && npm install
COPY config config/
ENV MIX_ENV=prod
RUN mix assets.deploy
# ====================================
# Stage 3: Build Release
# ====================================
FROM deps AS release_build
WORKDIR /app
# Copy compiled deps
COPY --from=deps /app/deps /app/deps
COPY --from=assets /app/priv/static /app/priv/static
# Cache-busting: force re-copy of application code
ARG CACHEBUST=3
RUN echo "Code cache bust: $CACHEBUST"
# Copy application code
COPY lib lib/
COPY config config/
COPY mix.exs mix.lock ./
COPY priv priv/
# Compile and build release
ENV MIX_ENV=prod
RUN mix compile
RUN mix release
# ====================================
# Stage 4: Runtime
# ====================================
FROM alpine:${ALPINE_VERSION} AS runtime
RUN apk add --no-cache \
libstdc++ \
openssl \
ncurses-libs \
ca-certificates \
rocksdb
# Create app user
RUN addgroup -g 1000 app && \
adduser -D -u 1000 -G app app
WORKDIR /app
USER app
# Copy release from build stage
COPY --from=release_build --chown=app:app /app/_build/prod/rel/singularity_edge ./
ENV HOME=/app
ENV MIX_ENV=prod
ENV PORT=8080
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/api/health || exit 1
CMD ["bin/singularity_edge", "start"]