# Start from Ubuntu base image
FROM ubuntu:latest
# Update package list and install necessary dependencies
RUN apt-get update && \
apt-get install -y curl gnupg2 ca-certificates lsb-release software-properties-common git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Nginx
RUN apt-get update && \
apt-get install -y nginx && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install PHP 8.2 and basic extensions
RUN add-apt-repository ppa:ondrej/php && \
apt-get update && \
apt-get install -y php8.2 php8.2-fpm php8.2-mysql php8.2-xml php8.2-mbstring php8.2-curl php8.2-gd php8.2-zip php8.2-redis && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy Nginx Config
COPY default /etc/nginx/sites-available/default
# Set working directory
WORKDIR /var/www/html
# Copy application code
RUN rm -rf /var/www/html/*
COPY . /var/www/html/
RUN chown -R www-data:www-data /var/www/html/
# Expose ports
EXPOSE 80
# Start Nginx and PHP-FPM in the foreground
CMD service php8.2-fpm start && nginx -g 'daemon off;'