65 lines
1.2 KiB
Docker
65 lines
1.2 KiB
Docker
|
|
# Build stage
|
||
|
|
FROM elixir:1.19.0-rc.0-otp-28-alpine AS build
|
||
|
|
|
||
|
|
# Install build dependencies
|
||
|
|
RUN apk add --no-cache build-base git nodejs npm
|
||
|
|
|
||
|
|
# Prepare build dir
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Install hex + rebar
|
||
|
|
RUN mix local.hex --force && \
|
||
|
|
mix local.rebar --force
|
||
|
|
|
||
|
|
# Set build ENV
|
||
|
|
ENV MIX_ENV=prod
|
||
|
|
|
||
|
|
# Install mix dependencies
|
||
|
|
COPY mix.exs mix.lock ./
|
||
|
|
RUN mix deps.get --only prod
|
||
|
|
RUN mix deps.compile
|
||
|
|
|
||
|
|
# Copy application files
|
||
|
|
COPY config config
|
||
|
|
COPY priv priv
|
||
|
|
COPY lib lib
|
||
|
|
COPY assets assets
|
||
|
|
|
||
|
|
# Compile assets
|
||
|
|
RUN npm ci --prefix ./assets
|
||
|
|
RUN npm run deploy --prefix ./assets
|
||
|
|
RUN mix assets.deploy
|
||
|
|
|
||
|
|
# Compile the project
|
||
|
|
RUN mix compile
|
||
|
|
|
||
|
|
# Build release
|
||
|
|
RUN mix release
|
||
|
|
|
||
|
|
# App stage
|
||
|
|
FROM alpine:3.19 AS app
|
||
|
|
|
||
|
|
# Install runtime dependencies
|
||
|
|
RUN apk add --no-cache libstdc++ openssl ncurses-libs
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy the release from build stage
|
||
|
|
COPY --from=build /app/_build/prod/rel/my_first_elixir_vibe_code ./
|
||
|
|
|
||
|
|
# Copy entrypoint script
|
||
|
|
COPY entrypoint.sh /entrypoint.sh
|
||
|
|
RUN chmod +x /entrypoint.sh
|
||
|
|
|
||
|
|
# Create a non-root user
|
||
|
|
RUN addgroup -g 1000 phoenix && \
|
||
|
|
adduser -D -u 1000 -G phoenix phoenix && \
|
||
|
|
chown -R phoenix:phoenix /app
|
||
|
|
|
||
|
|
USER phoenix
|
||
|
|
|
||
|
|
EXPOSE 4000
|
||
|
|
|
||
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
||
|
|
CMD ["bin/my_first_elixir_vibe_code", "start"]
|