1- # Using hexpm/elixir:1.11.4-erlang-23.2.7.2-alpine-3.13.3 as the base image
2- FROM hexpm/elixir:1.11.4-erlang-23.2.7.2-alpine-3.13.3 AS base
1+ FROM elixir:1.18.3-otp-27-slim AS base
32
4- # Set the working directory in the container
53WORKDIR /code_comparison
64
7- # Install system dependencies
8- # npm is needed for asset building.
9- # inotify-tools is often for development (auto-reload), might not be strictly needed for a prod build,
10- # but keeping it as per original Dockerfile's intent for now.
11- RUN apk add --no-cache npm inotify-tools
5+ # Install system dependencies first!
6+ RUN apt-get update && \
7+ apt-get install -y npm inotify-tools ca-certificates && \
8+ apt-get clean && \
9+ rm -rf /var/lib/apt/lists/*
1210
13- # Set environment variables for production
14- ENV MIX_ENV=prod
15- ENV PORT=4000
16-
17- # Copy the entire application source code into the working directory
18- # This includes the 'topics/' directory, mix files, config, lib, assets, etc.
19- COPY . .
20-
21- # Provide a dummy SECRET_KEY_BASE for compilation, must be at least 64 bytes long for prod.
22- # This will be overridden by the runtime environment variable on Render.
23- ENV SECRET_KEY_BASE="dummy_build_time_secret_key_base_must_be_at_least_64_bytes_long_for_prod_build_0123456789"
24-
25- # Install Elixir dependencies
26- # --force is used to ensure local hex and rebar are up-to-date
27- RUN mix local.hex --force && \
28- mix local.rebar --force && \
29- mix deps.get --only prod && \
30- mix deps.compile
31-
32- # Build frontend assets
33- # This assumes your assets/package.json has a "deploy" script.
34- # If not, you might use "build" or a direct webpack command.
35- # The --prefix flag tells npm to run the command in the ./assets directory.
36- RUN npm install --prefix ./assets && \
37- npm run deploy --prefix ./assets
38- # A common alternative if 'deploy' script is not set up:
39- # npm run --prefix ./assets build
40- # or direct webpack:
41- # ./assets/node_modules/.bin/webpack --mode production --config ./assets/webpack.config.js
42-
43- # Compile the Phoenix application and digest assets
44- # phx.digest prepares static assets (CSS, JS, images) for production.
45- RUN mix phx.digest && \
46- mix compile
47-
48- # Expose the port the application will run on
49- EXPOSE ${PORT}
50-
51- # Command to run the application
52- # For production, `mix release` is generally recommended.
53- # However, `mix phx.server` is simpler and can be used if that's the current deployment strategy.
54- CMD ["mix" , "phx.server" ]
11+ # Now it's safe to run mix commands
12+ RUN mix do local.hex --force, local.rebar --force
0 commit comments