Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.git
.github
vendor
node_modules
docs
.dockerignore
Dockerfile
docker-compose.yml
.gitignore
.gitattributes
README.md
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM php:8.3-cli

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
libxml2-dev \
libonig-dev \
zip \
&& rm -rf /var/lib/apt/lists/*

# Install PHP extensions required by the project
RUN docker-php-ext-install zip
RUN docker-php-ext-install dom
RUN docker-php-ext-install simplexml
RUN docker-php-ext-install mbstring
RUN docker-php-ext-configure pcntl --enable-pcntl && docker-php-ext-install pcntl

# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /var/www/html

# Copy project files
COPY . .

# Set up entrypoint
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]

# Install dependencies by default (can be overridden)
CMD ["composer", "install"]
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.PHONY: build install generate build-site serve test lint fix-lint coverage help

IMAGE_NAME = mergephp-website
CONTAINER_NAME = mergephp-website-container
HOST_PORT = 8000
CONTAINER_PORT = 8000

# Default target
help:
@echo "Available commands:"
@echo " make build - Build the Docker image"
@echo " make install - Install Composer dependencies"
@echo " make generate - Generate a new meetup"
@echo " make build-site - Build the static site"
@echo " make serve - Serve the site on localhost:$(HOST_PORT)"
@echo " make test - Run PHPUnit tests"
@echo " make lint - Check code style"
@echo " make fix-lint - Fix lint errors automatically"
@echo " make coverage - Generate code coverage report"
@echo " make bash - Open a bash shell in the container"

# Build the Docker image
build:
docker build -t $(IMAGE_NAME) .

# Install dependencies
install:
docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer install

# Generate a new meetup
generate: build
docker run --rm -it -v $(PWD):/var/www/html $(IMAGE_NAME) composer generate

# Build the static site
build-site: build
docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer build

# Serve the site
serve: build
docker run --rm -p $(HOST_PORT):$(CONTAINER_PORT) -v $(PWD):/var/www/html --name $(CONTAINER_NAME) $(IMAGE_NAME) php -S 0.0.0.0:$(CONTAINER_PORT) -t docs/

# Run tests
test: build
docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer test

# Run lint check
lint: build
docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer lint

# Fix lint errors
fix-lint: build
docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer fix-lint-errors

# Generate code coverage
coverage: build
docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer coverage

# Open a bash shell in the container
bash: build
docker run --rm -it -v $(PWD):/var/www/html $(IMAGE_NAME) bash
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
container_name: mergephp-website
volumes:
- .:/var/www/html
ports:
- "8000:8000"
command: php -S 0.0.0.0:8000 -t docs/
5 changes: 5 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

# Execute the command passed as arguments
exec "$@"