pdsinterop / php-solid-server

Standalone Solid Server written in PHP by PDS Interop
https://pdsinterop.org/php-solid-server/
MIT License
46 stars 7 forks source link

Instructions for running with docker-compose #40

Closed joepio closed 3 years ago

joepio commented 3 years ago

First off: awesome work! This really helps make the Solid ecosystem more mature :).

Since there's a docker-compose.yml file, I'd love to use that to run this project locally. However, I'm not getting it to work, and I'm not sure what I'm doing wrong.

When I run docker-compose up, the image is properly pulled and it's Attaching to solid-php-server, but from then on I can't get a connection. The compose file seems to correctly expose port 80, but I can't make a connection. Also, the logs are empty: docker logs solid_php.

Thanks in advance!

michielbdejong commented 3 years ago

I never tried the docker-compose but I think it should work with https://github.com/pdsinterop/php-solid-server/blob/master/run-solid-test-suite.sh#L9 https://github.com/pdsinterop/php-solid-server/blob/master/run-solid-test-suite.sh#L23

I'll see if I can set up a public instance

michielbdejong commented 3 years ago

I just tried:

docker build -t server .
docker run -d --network=host server

and now see 'Hello, World!' on https://pss.pdsinterop.net/

michielbdejong commented 3 years ago

When browsing to https://pss.pdsinterop.net/login I see '405 Method Not Allowed'. I tried fetch('', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: 'username=alice&password=alice123' }); from that page but got a 405 for that as well.

michielbdejong commented 3 years ago

Ah, https://pss.pdsinterop.net/profile/card#me shows something meaningful :)

michielbdejong commented 3 years ago

Here is the entire history from a clean Ubuntu server, including LetsEncrypt setup:

apt install certbot
certbot certonly --standalone

git clone https://github.com/pdsinterop/php-solid-server
cd php-solid-server
mkdir tls
cp /etc/letsencrypt/live/pss.pdsinterop.net/privkey.pem tls/server.key
cp /etc/letsencrypt/live/pss.pdsinterop.net/fullchain.pem tls/server.cert

snap install docker
docker build -t server .
docker run -d --network=host -e SERVER_ROOT=https://pss.pdsinterop.net -e USERNAME=alice -e PASSWORD=alice123 -v `pwd`/tls:/tls server
michielbdejong commented 3 years ago

And see https://pss.pdsinterop.net/storage/

ylebre commented 3 years ago

Adding on to the pile of information - I have an instance running locally with docker-compose, but the setup is different. It consist of these files: docker-compose.yml apache.conf php-solid-server/ php-solid-pubsub-server/

docker-compose.yml:

version: '3'
services:
    php-apache:
        build:
            context: ./php-apache
        ports:
            - 80:80
            - 443:443
            - 8080:8080
        volumes:
            - ./php-solid-server/:/var/www/
            - ./php-solid-pubsub-server/:/var/websocket/
            - ./apache.conf:/etc/apache2/sites-enabled/001-default-ssl.conf

apache.conf:

<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile /tls/server.cert
    SSLCertificateKeyFile /tls/server.key
    ServerName localhost
    DocumentRoot /var/www/html/
</VirtualHost>

and directories php-solid-server and php-solid-pubsub-server checked out from github.

The caveat is that the pubsub server has to be started up manually (php /var/websocket/server/server.php) from the commandline.

michielbdejong commented 3 years ago

So is https://github.com/pdsinterop/php-solid-server/blob/master/docker-compose.yml outdated? I see it's 5 months old, so probably it's better if you overwrite it with your working one?

michielbdejong commented 3 years ago

Or we remove the failing docker-compose.yml and add the steps from https://github.com/pdsinterop/php-solid-server/issues/40#issuecomment-749539591 to the readme?

Potherca commented 3 years ago

I think we would be better served updating the docker-compose file...

ylebre commented 3 years ago

I've updated the docker-compose so that it now runs the local Dockerfile and adds a pubsub server from git (php-solid-pubsub-server#master).

@joepio Could you see if this one starts everything up for you?

joepio commented 3 years ago

Almost there!

AH00526: Syntax error on line 29 of /etc/apache2/sites-enabled/site.conf:
Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

Seems to have an issue reading this line:

    Header add Access-Control-Allow-Origin "*"

Removing the line results in the same error, though. Might be a different issue!

ylebre commented 3 years ago

could you check what happens if you do 'a2enmod headers' on the commandline? I'm expecting it to say 'Module headers already enabled'. I would have expected the new Dockerfile to have handled that though, so maybe a 'docker-compose build php-solid-server' is needed to rebuild the image with mod_headers enabled?

joepio commented 3 years ago

docker-compose run php-solid-server a2enmod headers returned

Enabling module headers.
To activate the new configuration, you need to run:
  service apache2 restart

But... Indeed, after running docker-compose build php-solid-server, it seems to work fine! Thanks :)

Potherca commented 3 years ago

@joepio :tada:

@ylebre We'll have to investigate at a later moment what gives, as the Dockerfile contains a RUN a2enmod headers instruction.

Then again, when we finally move the Docker image created by/for this repo to Docker Hub, this issue should also be resolved.

Anyway... mañana.

ylebre commented 3 years ago

The a2enmod was a recent addition I did earlier today, which is also why the docker-compose build fixed it :)

michielbdejong commented 3 years ago

I shut down pss.pdsinterop.net again to save money, let me know if we need a public PSS server running again.

Potherca commented 3 years ago

@michielbdejong That shouldn't be needed. There's work underway for push-button deploys for Heroku et-al.