It looks like the WORKDIR inside my Dockerfile doesn't work. I'm trying this on Windows 10. The same works perfectly on Mac.
Here are my project files: docker-compose.yml:
version: '3'
services:
php_under_test:
build: tests/DockerImages/${PHP_VERSION}
volumes:
- .:/opt/project/phpstorm-stubs
test_runner:
build: tests/DockerImages/testRunner
volumes:
- .:/opt/project/phpstorm-stubs
The tests/DockerImages/testRunner folder has only this Dockerfile:
FROM php:8.1-apache
RUN echo 'memory_limit = 1024M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini
COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN apt-get update && apt-get -y install git zip unzip
WORKDIR /opt/project/phpstorm-stubs
If I run docker-compose -f docker-compose.yml run test_runner /usr/local/bin/php tests/Tools/generate-stub-map in cmd.exe in the same directory where docker-compose.yml lies, I would get:
C:\Projects\phpstorm-stubs>docker-compose -f docker-compose.yml run test_runner /usr/local/bin/php tests/Tools/generate-stub-map
WARNING: The PHP_VERSION variable is not set. Defaulting to a blank string.
Creating phpstorm-stubs_test_runner_run ... done
Could not open input file: tests/Tools/generate-stub-map
ERROR: 1
However, if I run the same using -w: docker-compose -f docker-compose.yml run -w /opt/project/phpstorm-stubs test_runner /usr/local/bin/php tests/Tools/generate-stub-map - that would work. Output:
C:\Projects\phpstorm-stubs>docker-compose -f docker-compose.yml run -w /opt/project/phpstorm-stubs test_runner /usr/local/bin/php tests/Tools/generate-stub-map
WARNING: The PHP_VERSION variable is not set. Defaulting to a blank string.
Creating phpstorm-stubs_test_runner_run ... done
Parsing "/opt/project/phpstorm-stubs/tests/Tools/../../aerospike/aerospike.php"
Parsing "/opt/project/phpstorm-stubs/tests/Tools/../../aerospike/Bytes.php"
etc...
I can see here that -w is outdated and I should use --project-directory instead, but doesn't work also:
C:\Projects\phpstorm-stubs>docker-compose -f docker-compose.yml --project-directory /opt/project/phpstorm-stubs run test_runner /usr/local/bin/php
tests/Tools/generate-stub-map
WARNING: The PHP_VERSION variable is not set. Defaulting to a blank string.
ERROR: build path C:\opt\project\phpstorm-stubs\tests\DockerImages either does not exist, is not accessible, or is not a valid URL.
I've tried to look for something related at docker/compose github issues but found none.
docker version output:
Client:
Cloud integration: v1.0.24
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:09:02 2022
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.10.1 (82475)
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:01:23 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.6
GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc:
Version: 1.1.2
GitCommit: v1.1.2-0-ga916309
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Any help with this is much appreciated.