Skip to content

Commit

Permalink
create a dockerfile to easily run the API
Browse files Browse the repository at this point in the history
without having to install PHP or required dependencies
  • Loading branch information
JohnRDOrazio committed Dec 28, 2024
1 parent a1c6a5c commit 03ea14c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*
!src
!i18n
!jsondata
!composer.json
!composer.lock
!LitCalTestServer.php
!index.php
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use the official PHP 8.3 CLI image as the base image
FROM php:8.3-cli

# Set the working directory
WORKDIR /var/www/html

# Install necessary PHP extensions
RUN apt update -y && \
apt upgrade -y && \
apt install -y --no-install-recommends libicu-dev libonig-dev libzip-dev locales-all && \
docker-php-ext-configure intl && \
docker-php-ext-install intl mbstring zip && \
docker-php-ext-enable intl mbstring zip

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy the current directory contents into the container
COPY . ./

# Set the environment variable
ENV PHP_CLI_SERVER_WORKERS=2

# Run composer install to install dependencies
RUN composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev

# Expose port 8000 to the host
EXPOSE 8000

# Command to run PHP's built-in server
CMD ["php", "-S", "0.0.0.0:8000", "-t", "/var/www/html"]

0 comments on commit 03ea14c

Please sign in to comment.