-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker #49
base: master
Are you sure you want to change the base?
Conversation
Update packages to newer versions Proxy based on URI path Dockerize all website components Fix cookie issues
@cboden Awesome! Will check it out locally and suggest some improvements, already spotted a few |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.)
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"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dockerfile: docker/Dockerfile-chat | |
dockerfile: docker/Dockerfile-chat | |
target: runtime |
@@ -158,4 +158,4 @@ ChatRoom = function(optDebug) { | |||
); | |||
|
|||
return api; | |||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
@@ -10,7 +10,9 @@ | |||
] | |||
, "require": { | |||
"php": ">=5.4.0" | |||
, "cboden/Ratchet": "0.3.*" | |||
, "cboden/ratchet": "^0.4" | |||
, "react/event-loop": "^1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, "react/event-loop": "^1.0" | |
, "react/event-loop": "^1.3" |
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(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either
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
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.
cc @WyriHaximus