Skip to content

Commit

Permalink
Merge pull request #2 from upmind/dev-env
Browse files Browse the repository at this point in the history
Dev env
  • Loading branch information
uphlewis authored Jan 16, 2025
2 parents d2b3a15 + 108f363 commit 346c961
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 346c961

Please sign in to comment.