Skip to content

Commit

Permalink
Merge pull request #15 from udx/UAT-68
Browse files Browse the repository at this point in the history
Improvements [UAT-68]
  • Loading branch information
fqjony authored Jan 16, 2025
2 parents 0f65b1f + 728f1cf commit fcea80d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Use the UDX worker as the base image
FROM usabilitydynamics/udx-worker:0.6.0
FROM usabilitydynamics/udx-worker:0.8.0

# Add metadata labels
LABEL maintainer="UDX"
LABEL version="0.6.0"

# Arguments and Environment Variables
ARG PHP_VERSION=8.3
ARG PHP_PACKAGE_VERSION=8.3.6-0ubuntu0.24.04.3
ARG NGINX_VERSION=1.24.0-2ubuntu7.1

# Set the PHP_VERSION as an environment variable
ENV PHP_VERSION="${PHP_VERSION}"

# Temporarily switch to root for package installation
Expand Down Expand Up @@ -36,10 +39,8 @@ COPY etc/php/php-fpm.conf /etc/php/"${PHP_VERSION}"/fpm/php-fpm.conf
COPY etc/php/www.conf /etc/php/"${PHP_VERSION}"/fpm/pool.d/www.conf

# Update default.conf with PHP socket and configure PHP-FPM with custom settings
RUN sed -i "s|\${PHP_VERSION}|${PHP_VERSION}|g" /etc/nginx/snippets/fastcgi-php"${PHP_VERSION}".conf

# Update default.conf with PHP socket and configure PHP-FPM with custom settings
RUN sed -i "s|\${PHP_VERSION}|${PHP_VERSION}|g" /etc/nginx/sites-available/default && \
RUN sed -i "s|\${PHP_VERSION}|${PHP_VERSION}|g" /etc/nginx/snippets/fastcgi-php"${PHP_VERSION}".conf && \
sed -i "s|\${PHP_VERSION}|${PHP_VERSION}|g" /etc/nginx/sites-available/default && \
sed -i "s|\${USER}|${USER}|g; s|\${PHP_VERSION}|${PHP_VERSION}|g" /etc/php/"${PHP_VERSION}"/fpm/pool.d/www.conf && \
grep -q "^include=/etc/php/${PHP_VERSION}/fpm/pool.d/*.conf" /etc/php/"${PHP_VERSION}"/fpm/php-fpm.conf || \
echo "include=/etc/php/${PHP_VERSION}/fpm/pool.d/*.conf" >> /etc/php/"${PHP_VERSION}"/fpm/php-fpm.conf
Expand Down Expand Up @@ -70,4 +71,4 @@ USER "${USER}"
VOLUME [ "/var/www", "/home/${USER}" ]
WORKDIR /var/www/html

CMD ["sh"]
CMD ["tail", "-f", "/dev/null"]
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ build:
fi
@echo "Docker image build completed."

# Run Docker container for default tests (e.g., tests in /src/tests directory)
# Run Docker container for default tests or in interactive mode based on INTERACTIVE variable
run: clean
@echo "Running Docker container for testing..."
@docker run -d --rm --name $(CONTAINER_NAME) \
@echo "Running Docker container $(if $(INTERACTIVE),in interactive mode,for testing)..."
@docker run $(if $(INTERACTIVE),-it --entrypoint $(CMD),-d) --rm --name $(CONTAINER_NAME) \
-v $(CURDIR)/$(SRC_PATH):$(CONTAINER_SRC_PATH) -p $(HOST_PORT):$(CONTAINER_PORT) \
$(DOCKER_IMAGE)
$(DOCKER_IMAGE) $(if $(INTERACTIVE),,$(CMD))
@$(MAKE) wait-container-ready
@docker logs -f $(CONTAINER_NAME)

# Deploy application with the pulled Docker Hub image and user-provided app code
deploy: clean
Expand All @@ -40,12 +39,12 @@ deploy: clean

# Run Docker container in interactive mode
run-it:
@$(MAKE) run INTERACTIVE=true CMD="/bin/sh"
@$(MAKE) run INTERACTIVE=true CMD="/bin/bash"

# Execute a command in the running container
exec:
@echo "Executing into Docker container..."
@docker exec -it $(CONTAINER_NAME) /bin/sh
@docker exec -it $(CONTAINER_NAME) /bin/bash

# View the container logs
log:
Expand Down
3 changes: 3 additions & 0 deletions Makefile.variables
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
DOCKER_IMAGE := usabilitydynamics/udx-worker-php:latest
CONTAINER_NAME := udx-worker-php-container

# Runtime Options
CMD ?= /bin/bash

# Platform and Build Configuration
MULTIPLATFORM := false
BUILD_PLATFORMS := linux/amd64,linux/arm64
Expand Down
5 changes: 3 additions & 2 deletions etc/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ server {
root /var/www/html;
index index.php index.html index.htm;

# Dynamic content funneled through index.php
location / {
try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
include snippets/fastcgi-php${PHP_VERSION}.conf;
}

location ~ /\.ht {
Expand Down

0 comments on commit fcea80d

Please sign in to comment.