# Use Ubuntu as the base image
FROM ubuntu:latest
#ENV DEBIAN_FRONTEND=noninteractive

# Set environment variables for MySQL
ENV MYSQL_ROOT_PASSWORD=rootpassword
ENV MYSQL_DATABASE=mydatabase
ENV MYSQL_USER=myuser
ENV MYSQL_PASSWORD=mypassword

# Update system packages
RUN apt-get update -y

# Install other useful utilities
RUN apt-get install -y vim tar unzip wget

# Install Apache
RUN apt-get install -y apache2

# Install MySQL
RUN apt-get install -y mysql-server

# Install ProFTPD
RUN apt-get install -y proftpd-basic

# Install Crontab
RUN apt-get install -y cron

# Install Python
RUN apt-get install -y python3-pip python3-venv
RUN python3 -m venv lamp_venv
# RUN source lamp_venv/bin/activate
# RUN pip install pymysql


# Install PHP and related modules
RUN apt-get install -y php php-mysql php-pdo php-cli php-gd php-mbstring

# Clean up after installation
RUN apt-get clean

# Copy the tar file
COPY ./backup-4.25.2024_18-48-55_kyaho3ki.tar.gz /
COPY ./app/lamp_account_restore.py /

# Start MySQL and run the SQL commands to set the authentication method
RUN service mysql start && \
    mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${MYSQL_ROOT_PASSWORD}'; FLUSH PRIVILEGES;"

# Expose necessary ports for Apache, MySQL, and FTP
EXPOSE 80 443 21 3306

# Start Apache, MySQL, and ProFTPD services in the background
CMD ["/bin/bash", "-c", "service apache2 start && service mysql start && service proftpd start && service cron start && tail -f /dev/null"]

# Build : podman build -t lamp-hosting-server-image -f PodmanfileLAMPHostingServer .
# Run : podman run -d -p 8081:80 -p 8082:443 -p 8083:21 -p 8084:3306 --name lamp-hosting-server lamp-hosting-server-image

