diff --git a/Dockerfile b/Dockerfile new file mode 100644 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +# Use Ubuntu 24.04 as a parent image +FROM ubuntu:24.04 + +# Set environment variables to non-interactive mode +ENV DEBIAN_FRONTEND=noninteractive +ENV MYSQL_ROOT_PASSWORD=password + +# Install required packages +RUN apt-get update +RUN apt-get install -y nginx +RUN apt-get install -y mysql-server +RUN apt-get install -y php-fpm +RUN apt-get install -y php-mysql +RUN apt-get install -y php-mbstring +RUN apt-get install -y php-iconv +RUN apt-get install -y php-curl +RUN apt-get install -y php-gd +RUN apt-get install -y php-zip +RUN apt-get install -y git +RUN apt-get install -y curl +RUN apt-get install -y unzip +RUN apt-get clean + +# Set up MySQL user and database +RUN service mysql start && \ + mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY '${MYSQL_ROOT_PASSWORD}';" && \ + mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "FLUSH PRIVILEGES;" + +# Clone Phorge repositories +RUN mkdir -p /var/www/phorge +RUN git clone https://we.phorge.it/source/arcanist.git /var/www/phorge/arcanist +RUN git clone https://we.phorge.it/source/phorge.git /var/www/phorge/phorge +RUN git config --system --add safe.directory /var/www/phorge/arcanist +RUN git config --system --add safe.directory /var/www/phorge/phorge + +# Set permissions +RUN chown -R www-data:www-data /var/www/phorge + +# Configure Nginx +RUN rm /etc/nginx/sites-enabled/default +COPY phorge-nginx.conf /etc/nginx/sites-available/phorge +RUN ln -s /etc/nginx/sites-available/phorge /etc/nginx/sites-enabled/ + +# Expose ports +EXPOSE 80 + +# Configure phorge +WORKDIR /var/www/phorge/phorge +RUN ./bin/config set mysql.host localhost +RUN ./bin/config set mysql.user root +RUN ./bin/config set mysql.pass ${MYSQL_ROOT_PASSWORD} + +# Start services +CMD service mysql start && service php8.3-fpm start && nginx -g "daemon off;" diff --git a/phorge-nginx.conf b/phorge-nginx.conf new file mode 100644 --- /dev/null +++ b/phorge-nginx.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name localhost; + + root /var/www/phorge/phorge/webroot; + index index.php; + + location / { + try_files $uri /index.php?__path__=$uri&$args; + } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/run/php/php8.3-fpm.sock; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param __path__ $uri; + include fastcgi_params; + } + + location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { + expires max; + log_not_found off; + } +}