-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
55 lines (42 loc) · 1.42 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Use an official PHP image as the base image
FROM php:7.4-apache
# Copy the application code to the container
COPY Source code/ /var/www/html/
# Copy the database file to the container
COPY database.sql /
# Install required PHP extensions
RUN apt-get update && apt-get install -y \
mysql-client \
libmcrypt-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
libzip-dev \
&& docker-php-ext-install \
mysqli \
pdo_mysql \
mbstring \
gd
# Install phpMyAdmin
RUN apt-get update && apt-get install -y \
phpmyadmin
# Copy the phpMyAdmin config to the Apache config directory
COPY Source code/phpmyadmin.conf /etc/apache2/conf-available/
# Enable the phpMyAdmin config
RUN a2enconf phpmyadmin
# Set the environment variables
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
# Update the document root in the Apache config
RUN sed -i -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!" /etc/apache2/sites-available/*.conf
# Import the database
RUN mysql -u root -p password < database.sql
# Update the database configuration
RUN sed -i "s/database_name_here/invite/g" /var/www/html/app/config/database.php \
&& sed -i "s/username_here/root/g" /var/www/html/app/config/database.php \
&& sed -i "s/password_here/password/g" /var/www/html/app/config/database.php
# Restart Apache to apply the changes
RUN service apache2 restart
# Expose port 80 to the host
EXPOSE 80
# Start Apache
CMD ["apache2-foreground"]