File tree Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Deploy to GitHub Container Registry
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+
8
+ jobs :
9
+ deploy :
10
+ runs-on : ubuntu-latest
11
+
12
+ permissions :
13
+ contents : read
14
+ packages : write # Required to push to GitHub Container Registry
15
+
16
+ steps :
17
+ # Checkout the code
18
+ - name : Checkout Code
19
+ uses : actions/checkout@v3
20
+
21
+ # Authenticate to GitHub Container Registry
22
+ - name : Log in to GitHub Container Registry
23
+ run : |
24
+ echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
25
+
26
+ # Build and tag the Docker image
27
+ - name : Build and Tag Docker Image
28
+ run : |
29
+ docker build -t laravel-php-mariadb-demo .
30
+ docker tag laravel-php-mariadb-demo:latest ghcr.io/${{ github.repository_owner }}/laravel-php-mariadb-demo:latest
31
+
32
+ # Push the Docker image to GHCR
33
+ - name : Push Docker Image to GitHub Container Registry
34
+ run : |
35
+ docker push ghcr.io/${{ github.repository_owner }}/laravel-php-mariadb-demo:latest
Original file line number Diff line number Diff line change
1
+ # Use the official PHP lightweight image with Apache
2
+ FROM php:9.2-apache
3
+
4
+ # Set working directory
5
+ WORKDIR /var/www/html
6
+
7
+ # Copy project files
8
+ COPY . .
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y \
12
+ libpng-dev \
13
+ libjpeg-dev \
14
+ libfreetype6-dev \
15
+ && docker-php-ext-configure gd --with-freetype --with-jpeg \
16
+ && docker-php-ext-install gd \
17
+ && docker-php-ext-install pdo pdo_mysql
18
+
19
+ # Install Composer
20
+ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
21
+
22
+ # Install PHP dependencies
23
+ RUN composer install --no-interaction --prefer-dist --optimize-autoloader
24
+
25
+ # Expose port 80
26
+ EXPOSE 80
27
+
28
+ # Set entrypoint
29
+ CMD ["apache2-foreground" ]
Original file line number Diff line number Diff line change
1
+ version : ' 3.8'
2
+
3
+ services :
4
+ app :
5
+ build :
6
+ context : .
7
+ dockerfile : Dockerfile
8
+ ports :
9
+ - " 80:80"
10
+ volumes :
11
+ - .:/var/www/html
12
+ env_file :
13
+ - .env
14
+ depends_on :
15
+ - db
16
+
17
+ db :
18
+ image : mariadb:10
19
+ restart : always
20
+ ports :
21
+ - " 3306:3306"
22
+ environment :
23
+ MYSQL_DATABASE : ${DB_DATABASE}
24
+ MYSQL_USER : ${DB_USERNAME}
25
+ MYSQL_PASSWORD : ${DB_PASSWORD}
26
+ MYSQL_ROOT_PASSWORD : ${DB_PASSWORD}
27
+ volumes :
28
+ - db_data:/var/lib/mysql
29
+
30
+ volumes :
31
+ db_data:
You can’t perform that action at this time.
0 commit comments