Skip to content

Commit 3af96d1

Browse files
authored
Merge pull request #1 from ohdoking/ss_vwk64i
[🤖 Infrapal Bot]Add Dockerfile, GitHub workflow, and Docker Compose
2 parents 12ca173 + ba0c87c commit 3af96d1

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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"]

docker-compose.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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:

0 commit comments

Comments
 (0)