47 lines
1.1 KiB
Docker
47 lines
1.1 KiB
Docker
# Use the official Elixir image with OTP 26 and Elixir 1.15
|
|
FROM elixir:1.15-otp-26-slim
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
git \
|
|
curl \
|
|
build-essential \
|
|
inotify-tools \
|
|
postgresql-client \
|
|
sudo \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Node.js 20 (needed for assets compilation)
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
&& apt-get install -y nodejs
|
|
|
|
# Create a non-root user
|
|
RUN groupadd --gid 1000 vscode \
|
|
&& useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode \
|
|
&& echo 'vscode ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
|
|
|
# Set the working directory
|
|
WORKDIR /workspace
|
|
|
|
# Copy the project files
|
|
COPY --chown=vscode:vscode . /workspace
|
|
|
|
# Install Hex and Rebar
|
|
RUN mix local.hex --force && \
|
|
mix local.rebar --force
|
|
|
|
# Switch to vscode user
|
|
USER vscode
|
|
|
|
# Install Phoenix
|
|
RUN mix archive.install hex phx_new --force
|
|
|
|
# Set environment variables
|
|
ENV MIX_ENV=dev
|
|
ENV PHX_SERVER=true
|
|
|
|
# Expose port 4000 for Phoenix
|
|
EXPOSE 4000
|
|
|
|
# Default command
|
|
CMD ["tail", "-f", "/dev/null"] |