Skip to content

Commit a1dd48d

Browse files
authored
Merge pull request #70 from LuizBoina/master
Adding Dockerfile to Run progpilot Inside Container
2 parents 1e271a2 + ea68a7d commit a1dd48d

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.git
2+
.gitignore
3+
.gitattributes
4+
.github
5+
.devcontainer
6+
docs
7+
projects/tests
8+
projects/example
9+
projects/example_config
10+
*.md
11+
LICENSE
12+
grumphp.yml
13+
progpilot.yml
14+
builds
15+
vendor
16+
composer.lock

DOCKER.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Docker Usage
2+
3+
This document explains how to use progpilot with Docker.
4+
5+
## Building the Docker Image
6+
7+
```bash
8+
docker build -t progpilot .
9+
```
10+
11+
## Usage
12+
13+
### Basic Usage
14+
15+
```bash
16+
# Analyze a single PHP file
17+
docker run -v $(pwd):/workspace progpilot /workspace/path/to/your/file.php
18+
19+
# Analyze multiple files
20+
docker run -v $(pwd):/workspace progpilot /workspace/file1.php /workspace/file2.php /workspace/file3.php
21+
22+
# Analyze a directory
23+
docker run -v $(pwd):/workspace progpilot /workspace/path/to/your/php/project/
24+
25+
# Use with configuration file
26+
docker run -v $(pwd):/workspace progpilot /workspace/file.php --configuration /workspace/config.yml
27+
```
28+
29+
### Examples
30+
31+
```bash
32+
# Analyze current directory (mount current directory)
33+
docker run -v $(pwd):/workspace progpilot /workspace/
34+
35+
# Analyze with custom configuration
36+
docker run -v $(pwd):/workspace progpilot /workspace/ --configuration /workspace/progpilot.yml
37+
38+
# Analyze specific files in current directory
39+
docker run -v $(pwd):/workspace progpilot /workspace/index.php /workspace/config.php
40+
41+
# Test with the example file
42+
docker run -v $(pwd):/workspace progpilot /workspace/projects/example/source_code1.php
43+
```
44+
45+
## Volume Mounting
46+
47+
Since the container needs access to your PHP files, you'll need to mount volumes:
48+
49+
- `-v $(pwd):/workspace`: Mount your current directory to `/workspace` in the container
50+
- Use absolute paths inside the container for the files/directories you want to analyze
51+
- The `/workspace` path inside the container corresponds to your current directory
52+
53+
## Configuration Files
54+
55+
If you're using a configuration file, make sure to:
56+
1. Mount the directory containing your config file
57+
2. Use the container path when referencing the config file
58+
59+
## Notes
60+
61+
- The container builds the progpilot phar file during the build process
62+
- All arguments passed to the container are forwarded to the progpilot command
63+
- The container uses PHP 8.1 which is compatible with the project requirements (>=7.4)
64+
- Make sure to use the correct file paths when mounting volumes

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Use PHP 8.1 as base image (compatible with >=7.4 requirement)
2+
FROM php:8.1-cli
3+
4+
# Install system dependencies
5+
RUN apt-get update && apt-get install -y \
6+
git \
7+
unzip \
8+
wget \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Install Composer
12+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
13+
14+
# Install phar-composer tool
15+
RUN wget -O /usr/local/bin/phar-composer.phar https://github.com/clue/phar-composer/releases/download/v1.4.0/phar-composer-1.4.0.phar \
16+
&& chmod +x /usr/local/bin/phar-composer.phar
17+
18+
# Set working directory
19+
WORKDIR /app
20+
21+
# Copy project files
22+
COPY . .
23+
24+
# Build the phar file
25+
RUN chmod +x build.sh \
26+
&& ./build.sh
27+
28+
# Create a simple entrypoint script
29+
RUN echo '#!/bin/bash\n\
30+
if [ $# -eq 0 ]; then\n\
31+
echo "Usage: docker run progpilot <path1> [path2] [path3] ..."\n\
32+
echo "Example: docker run progpilot /path/to/php/files/ --configuration config.yml"\n\
33+
exit 1\n\
34+
fi\n\
35+
\n\
36+
# Find the latest built phar file\n\
37+
PHAR_FILE=$(ls -t builds/progpilot_*.phar 2>/dev/null | head -1)\n\
38+
\n\
39+
if [ ! -f "$PHAR_FILE" ]; then\n\
40+
echo "Error: No phar file found in builds directory"\n\
41+
exit 1\n\
42+
fi\n\
43+
\n\
44+
# Execute progpilot with all arguments\n\
45+
php "$PHAR_FILE" "$@"' > /entrypoint.sh \
46+
&& chmod +x /entrypoint.sh
47+
48+
# Set the entrypoint
49+
ENTRYPOINT ["/entrypoint.sh"]
50+
51+
# Default command (will show usage if no arguments provided)
52+
CMD []

0 commit comments

Comments
 (0)