diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ad635d7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Base image with PHP 7.4 +FROM php:7.4-cli + +# Arguments to capture UID and GID +ARG HOSTUID +ARG HOSTGID + +# Install Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +# Install necessary tools +RUN apt-get update && apt-get install -y \ + sudo \ + git \ + unzip \ + && apt-get clean + +# Create a group and user with matching UID/GID +RUN groupadd -g ${HOSTGID} developer \ + && useradd -m -u ${HOSTUID} -g ${HOSTGID} -s /bin/bash developer \ + && usermod -aG sudo developer \ + && echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +# Set permissions for the working directory +WORKDIR /app +RUN chown -R developer:developer /app + +# Switch to the new user +USER developer + +# Default shell command +CMD ["/bin/bash"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8bc99b6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ + +services: + php: + build: + context: . + dockerfile: Dockerfile + args: + HOSTUID: "${HOSTUID:-1001}" + HOSTGID: "${HOSTGID:-1001}" + container_name: php74-dev + volumes: + - .:/app + working_dir: /app + tty: true + stdin_open: true