Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerization #828

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Build stage
FROM elixir:1.14.1 as builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Set build ENV
ENV MIX_ENV=prod

# Install hex and rebar
RUN mix local.hex --force && \
mix local.rebar --force

# Copy configuration files first
COPY mix.exs mix.lock ./
COPY config config

# Install mix dependencies
RUN mix deps.get --only prod && \
mix deps.compile

# Copy assets directory and install npm dependencies
COPY assets assets
RUN npm install --prefix assets/

# Copy all remaining application files
COPY . .

# Compile assets and digest
RUN mix assets.deploy
RUN mix phx.digest

# Compile the application
RUN mix compile

# Build release
RUN mix release

# Final stage
FROM debian:bullseye-slim

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
openssl \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy release from builder
COPY --from=builder /app/_build/prod/rel/tilex ./

# Set environment variables
ENV PORT=4000

# Expose port
EXPOSE 4000

# Start the application
CMD ["bin/tilex", "start"]