Conversation
Update packages to newer versions Proxy based on URI path Dockerize all website components Fix cookie issues
Contributor
|
@cboden Awesome! Will check it out locally and suggest some improvements, already spotted a few |
WyriHaximus
reviewed
Jan 31, 2023
Contributor
WyriHaximus
left a comment
There was a problem hiding this comment.
Main questions:
- Why 7.4? In theory, it should work on 8.1 and maybe 8.2
- Couldn't get it to work locally
- Why not go fully single container? (But that could be a second step.)
Comment on lines
+1
to
+20
| FROM wyrihaximusnet/php:7.4-nts-alpine | ||
|
|
||
| RUN mkdir -p /opt/app/socketo.me | ||
| WORKDIR /opt/app/socketo.me | ||
|
|
||
| RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
| RUN php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | ||
| RUN php composer-setup.php | ||
| RUN rm composer-setup.php | ||
| RUN chmod +x composer.phar | ||
|
|
||
| COPY bin bin | ||
| COPY src src | ||
| COPY composer.json ./ | ||
| COPY composer.lock ./ | ||
| RUN ./composer.phar install --ansi --no-interaction --prefer-dist -o --no-scripts --no-plugins | ||
| RUN rm composer.phar | ||
|
|
||
| ENTRYPOINT ["php"] | ||
| CMD ["bin/run-all-the-things.php"] |
Contributor
There was a problem hiding this comment.
Would rewrite the Docker file to this mainly for size reasons: The original image is 434MB, using the slim image brings it down to 394MB. But installing the dependencies in a different stage and copying the entire thing over brings it down to 242MB.
Suggested change
| FROM wyrihaximusnet/php:7.4-nts-alpine | |
| RUN mkdir -p /opt/app/socketo.me | |
| WORKDIR /opt/app/socketo.me | |
| RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
| RUN php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
| RUN php composer-setup.php | |
| RUN rm composer-setup.php | |
| RUN chmod +x composer.phar | |
| COPY bin bin | |
| COPY src src | |
| COPY composer.json ./ | |
| COPY composer.lock ./ | |
| RUN ./composer.phar install --ansi --no-interaction --prefer-dist -o --no-scripts --no-plugins | |
| RUN rm composer.phar | |
| ENTRYPOINT ["php"] | |
| CMD ["bin/run-all-the-things.php"] | |
| FROM wyrihaximusnet/php:7.4-nts-alpine-slim-dev AS install-dependencies | |
| RUN mkdir -p /opt/app/socketo.me | |
| WORKDIR /opt/app/socketo.me | |
| COPY bin bin | |
| COPY src src | |
| COPY composer.* ./ | |
| RUN composer install --ansi --no-interaction --prefer-dist -o --no-scripts --no-plugins --no-dev | |
| FROM wyrihaximusnet/php:7.4-nts-alpine-slim AS runtime | |
| RUN mkdir -p /opt/app/socketo.me | |
| WORKDIR /opt/app/socketo.me | |
| COPY --from=install-dependencies /opt/app/socketo.me/ /opt/app/socketo.me/ | |
| ENTRYPOINT ["php"] | |
| CMD ["bin/run-all-the-things.php"] |
| chat: | ||
| build: | ||
| context: ./ | ||
| dockerfile: docker/Dockerfile-chat |
Contributor
There was a problem hiding this comment.
Suggested change
| dockerfile: docker/Dockerfile-chat | |
| dockerfile: docker/Dockerfile-chat | |
| target: runtime |
| @@ -158,4 +158,4 @@ ChatRoom = function(optDebug) { | |||
| ); | |||
|
|
|||
| return api; | |||
| }; | |||
| "php": ">=5.4.0" | ||
| , "cboden/Ratchet": "0.3.*" | ||
| , "cboden/ratchet": "^0.4" | ||
| , "react/event-loop": "^1.0" |
Contributor
There was a problem hiding this comment.
Suggested change
| , "react/event-loop": "^1.0" | |
| , "react/event-loop": "^1.3" |
Comment on lines
+42
to
+54
| Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) { | ||
| echo 'Received signal: ', (string)$signal, PHP_EOL; | ||
|
|
||
| Loop::removeSignal(SIGINT, $func); | ||
| Loop::get()->stop(); | ||
| }); | ||
| Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) { | ||
| echo 'Received signal: ', (string)$signal, PHP_EOL; | ||
|
|
||
| Loop::removeSignal(SIGTERM, $func); | ||
| Loop::get()->stop(); | ||
| }); | ||
|
|
Contributor
There was a problem hiding this comment.
Either
Suggested change
| Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) { | |
| echo 'Received signal: ', (string)$signal, PHP_EOL; | |
| Loop::removeSignal(SIGINT, $func); | |
| Loop::get()->stop(); | |
| }); | |
| Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) { | |
| echo 'Received signal: ', (string)$signal, PHP_EOL; | |
| Loop::removeSignal(SIGTERM, $func); | |
| Loop::get()->stop(); | |
| }); | |
| Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) { | |
| echo 'Received signal: ', (string)$signal, PHP_EOL; | |
| Loop::get()->stop(); | |
| }); | |
| Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) { | |
| echo 'Received signal: ', (string)$signal, PHP_EOL; | |
| Loop::get()->stop(); | |
| }); | |
or
Suggested change
| Loop::addSignal(SIGINT, $func = function ($signal) use (&$func) { | |
| echo 'Received signal: ', (string)$signal, PHP_EOL; | |
| Loop::removeSignal(SIGINT, $func); | |
| Loop::get()->stop(); | |
| }); | |
| Loop::addSignal(SIGTERM, $func = function ($signal) use (&$func) { | |
| echo 'Received signal: ', (string)$signal, PHP_EOL; | |
| Loop::removeSignal(SIGTERM, $func); | |
| Loop::get()->stop(); | |
| }); | |
| $func = function ($signal) use ($func) { | |
| echo 'Received signal: ', (string)$signal, PHP_EOL; | |
| Loop::removeSignal(SIGINT, $func); | |
| Loop::removeSignal(SIGTERM, $func); | |
| Loop::get()->stop(); | |
| }; | |
| Loop::addSignal(SIGINT, $func); | |
| Loop::addSignal(SIGTERM, $func); | |
But probably also a stop function, if it doesn't exists on Ratchet, would help.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cc @WyriHaximus