-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (45 loc) · 1.54 KB
/
Dockerfile
File metadata and controls
62 lines (45 loc) · 1.54 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
# Multi-stage Dockerfile using NixOS for Reencodarr Elixir/Phoenix app
FROM nixos/nix:latest AS builder
# Enable experimental features for flakes
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
# Set working directory
WORKDIR /app
# Copy flake files first for better caching
COPY flake.nix flake.lock ./
# Copy the entire source
COPY . .
# Build the application using nix flake
RUN nix develop --command bash -c "\
mix deps.get --only prod && \
MIX_ENV=prod mix compile && \
MIX_ENV=prod mix assets.deploy && \
MIX_ENV=prod mix release \
"
# Production stage - using a lighter base with nix
FROM nixos/nix:latest AS runtime
# Enable experimental features for flakes
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
# Create app user
RUN addgroup -g 1001 -S app && \
adduser -u 1001 -S app -G app
# Set working directory
WORKDIR /app
# Copy flake files for runtime dependencies
COPY flake.nix flake.lock ./
# Install runtime dependencies including ffmpeg and other tools
RUN nix develop --command bash -c "echo 'Runtime environment prepared'"
# Copy the release from builder stage
COPY --from=builder --chown=app:app /app/_build/prod/rel/reencodarr ./
# Switch to app user
USER app
# Expose port
EXPOSE 4000
# Environment variables
ENV MIX_ENV=prod
ENV PHX_SERVER=true
ENV PORT=4000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -sf http://localhost:4000/api/health || exit 1
# Start the application
CMD ["./bin/reencodarr", "start"]