Compare commits
4 Commits
3fc98af139
...
3777c45c16
Author | SHA1 | Date | |
---|---|---|---|
|
3777c45c16 | ||
|
5ff422a5f7 | ||
|
7e0f31726f | ||
|
a3b4a220c6 |
31
.docker-compose/nginx/cojedzie-rr.conf
Normal file
31
.docker-compose/nginx/cojedzie-rr.conf
Normal file
@ -0,0 +1,31 @@
|
||||
server {
|
||||
root /var/www/front/public/;
|
||||
|
||||
server_name cojedzie.localhost;
|
||||
|
||||
location /_profiler/ {
|
||||
try_files $uri $uri/ @api;
|
||||
}
|
||||
|
||||
location /bundles/ {
|
||||
try_files $uri $uri/ @api;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
try_files $uri $uri/ @api;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ @frontend;
|
||||
}
|
||||
|
||||
location @frontend {
|
||||
proxy_pass http://frontend:3000;
|
||||
proxy_intercept_errors on;
|
||||
}
|
||||
|
||||
location @api {
|
||||
proxy_pass http://api:8080;
|
||||
proxy_intercept_errors on;
|
||||
}
|
||||
}
|
71
CLA.md
Normal file
71
CLA.md
Normal file
@ -0,0 +1,71 @@
|
||||
# Co Jedzie Individual Contributor License Agreement
|
||||
|
||||
Adapted from http://www.apache.org/licenses/icla.txt © The Apache Software Foundation
|
||||
|
||||
Thank you for your interest in Co Jedzie (the **"Project"**) by Kacper Donat (the **"Author"**). In order to clarify the
|
||||
intellectual property license granted with Contributions from any person or entity, the Author must have a Contributor
|
||||
License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms
|
||||
below. This license is for your protection as a Contributor as well as the protection of the Author and its users; it
|
||||
does not change your rights to use your own Contributions for any other purpose.
|
||||
|
||||
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the
|
||||
Author. In return, the Author shall not use Your Contributions in a way that is contrary to the public benefit or
|
||||
inconsistent with its bylaws in effect at the time of the Contribution. Except for the license granted herein to the
|
||||
Author and recipients of software distributed by the Author, You reserve all right, title, and interest in and to Your
|
||||
Contributions.
|
||||
|
||||
1. Definitions.
|
||||
- **"You"** (or **"Your"**) shall mean the copyright owner or legal entity authorized by the copyright owner that is
|
||||
making this Agreement with the Author. For legal entities, the entity making a Contribution and all other entities
|
||||
that control, are controlled by, or are under common control with that entity are considered to be a single
|
||||
Contributor. For the purposes of this definition, **"control"** means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or
|
||||
more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
- **"Contribution"** shall mean any original work of authorship, including any modifications or additions to an existing
|
||||
work, that is intentionally submitted by You to the Author for inclusion in, or documentation of, any of the products
|
||||
owned or managed by the Author (the **"Work"**). For the purposes of this definition, **"submitted"** means any form
|
||||
of electronic, verbal, or written communication sent to the Author or its representatives, including but not limited
|
||||
to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed
|
||||
by, or on behalf of, the Author for the purpose of discussing and improving the Work, but excluding communication that
|
||||
is conspicuously marked or otherwise designated in writing by You as **"Not a Contribution."**
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to the Author and
|
||||
to recipients of software distributed by the Author a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform,
|
||||
sublicense, re-license, and distribute Your Contributions and such derivative works.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to the Author and to
|
||||
recipients of software distributed by the Author a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import,
|
||||
and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are
|
||||
necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which
|
||||
such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (
|
||||
including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have
|
||||
contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity
|
||||
under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. You represent that you are legally entitled to grant the above license. If your employer(s) has rights to
|
||||
intellectual property that you create that includes your Contributions, you represent that you have received
|
||||
permission to make Contributions on behalf of that employer, that your employer has waived such rights for your
|
||||
Contributions to the Author, or that your employer has executed a separate Corporate CLA with the Author.
|
||||
|
||||
5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of
|
||||
others). You represent that Your Contribution submissions include complete details of any third-party license or
|
||||
other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware
|
||||
and which are associated with any part of Your Contributions.
|
||||
|
||||
6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support.
|
||||
You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in
|
||||
writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
||||
express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT,
|
||||
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
7. Should You wish to submit work that is not Your original creation, You may submit it to the Author separately from
|
||||
any Contribution, identifying the complete details of its source and of any license or other restriction (including,
|
||||
but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and
|
||||
conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".
|
||||
|
||||
8. You agree to notify the Author of any facts or circumstances of which you become aware that would make these
|
||||
representations inaccurate in any respect.
|
||||
|
38
CONTRIBUTING.md
Normal file
38
CONTRIBUTING.md
Normal file
@ -0,0 +1,38 @@
|
||||
# How to contribute?
|
||||
|
||||
Thanks for your interest in the project!
|
||||
|
||||
## I'd like to propose some feature / change...
|
||||
|
||||
Cool! Go ahead, [create an issue] and describe your proposal so anyone can see it. You can also vote on features that
|
||||
you want the most.
|
||||
|
||||
## I've found a bug!
|
||||
|
||||
Well, less cool! Before creating an issue, please check if the bug remains after hard refreshing (usually `ctrl+F5`) the
|
||||
application. If the answer is yes, or this is not the first encounter of it please [create an issue] and describe the
|
||||
problem. If you can, please attach screenshots (especially if this is visual bug), and console logs (especially for
|
||||
connection problems) - this will help to reproduce the problem.
|
||||
|
||||
## I've got some spare resources on my server...
|
||||
Soon you will be able to help the project by hosting your own API node that will be available for clients to use.
|
||||
More details to come soon.
|
||||
|
||||
## I want to contribute some code...
|
||||
|
||||
That's great! If you want to make changes to API (which is responsible for collecting and supplying applicaiton with
|
||||
data) please check the [API contribution guidelines], if you are interested in UI side of the app please read the
|
||||
[frontend contribution guidelines].
|
||||
|
||||
### Contributor License Agreement
|
||||
|
||||
Unfortunately due to this project nature and license I need you to sign [Contributor License Agreement] - the nice thing
|
||||
is that it can be done with simple push of a button! **You still will have full copyright to your contribution** but
|
||||
basically you consent that you are entitled to code you are submitting and also to allow me to license this project on
|
||||
other terms if needed to, for example, local governments. If you don't want to sign - I understand - but I won't be able
|
||||
to accept your contribution :(
|
||||
|
||||
[Contributor License Agreement]: ./CLA.md
|
||||
[create an issue]: https://github.com/cojedzie/cojedzie/issues/new
|
||||
[API contribution guidelines]: ./api/CONTRIBUTING.md
|
||||
[frontend contribution guidelines]: ./front/CONTRIBUTING.md
|
19
README.md
19
README.md
@ -7,19 +7,26 @@ aims to be the central hub for all public transport information you will need.
|
||||
|
||||
You can use the app at [cojedzie.pl](https://cojedzie.pl).
|
||||
|
||||
## Contributing
|
||||
Want to contribute?
|
||||
|
||||
|
||||
## Roadmap
|
||||
Co Jedzie is in active development, roadmap of the project can be found on [trello]. This roadmap is regularly updated
|
||||
and represents current state of the project. Feel free to take a look.
|
||||
and represents current state of the project. Feel free to take a look.
|
||||
|
||||
### Contributing to roadmap
|
||||
If you have found a bug or want to propose some changes feel free to create an [issue] explaining your proposal or
|
||||
problem. Issue management and discussion would be done on the github, but planning will be carried away to the [trello]
|
||||
trello with linked issue.
|
||||
|
||||
## Contributing
|
||||
Wan't to contribute? Nice! Please see [CONTRIBUTING.md]
|
||||
|
||||
## License
|
||||
This project is [fair-code](https://faircode.io/) licensed under [MIT with Commons Clause](./LICENSE.md). Basically, Co
|
||||
Jedzie is free and code is available to everyone, but it's not allowed to make money directly with it.
|
||||
Jedzie is free and code is available to everyone, but it's not allowed to make money directly with it without
|
||||
authors permission.
|
||||
|
||||
Note that data collected from available data sources is licensed by their respective owners, thus it may be
|
||||
available under different terms than the project itself and may require additional permissions to use.
|
||||
|
||||
[trello]: https://trello.com/b/QXqDvmoG/co-jedzie
|
||||
[issue]: https://github.com/cojedzie/cojedzie/issues/new
|
||||
[CONTRIBUTING.md]: ./CONTRIBUTING.md
|
||||
|
3
api/CONTRIBUTING.md
Normal file
3
api/CONTRIBUTING.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Contributing guidelines
|
||||
|
||||
TBD
|
@ -1,7 +1,5 @@
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
ENV DATABASE_URL="sqlite:///var/db/app.db"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
|
29
api/rr.Dockerfile
Normal file
29
api/rr.Dockerfile
Normal file
@ -0,0 +1,29 @@
|
||||
FROM cojedzie/api:latest-rr
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
RUN install-php-extensions xdebug-^3.0;
|
||||
RUN apk add git;
|
||||
|
||||
# XDebug
|
||||
RUN echo "xdebug.mode=debug" >> $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini && \
|
||||
echo "xdebug.client_host=172.17.0.1" >> $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini && \
|
||||
echo "xdebug.start_with_request=On" >> $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini;
|
||||
|
||||
# Blackfire
|
||||
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
|
||||
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
|
||||
&& mkdir -p /tmp/blackfire \
|
||||
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
|
||||
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
|
||||
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
|
||||
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
|
||||
|
||||
# Timezone
|
||||
RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime && \
|
||||
echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini;
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
EXPOSE 9001
|
@ -29,7 +29,7 @@ class WithDestinationsDatabaseHandler implements PostProcessingHandler
|
||||
|
||||
if ($this->converter instanceof CacheableConverter) {
|
||||
$this->converter = clone $this->converter;
|
||||
$this->converter->flushCache();
|
||||
$this->converter->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@ class ZtmGdanskProvider implements Provider
|
||||
private $stops;
|
||||
private $tracks;
|
||||
private $messages;
|
||||
|
||||
/** @var ProviderEntity */
|
||||
private $entity;
|
||||
private $trips;
|
||||
|
||||
private ProviderEntity $entity;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'MZKZG - Trójmiasto';
|
||||
@ -68,7 +68,9 @@ class ZtmGdanskProvider implements Provider
|
||||
ZtmGdanskMessageRepository $messages,
|
||||
ReferenceFactory $referenceFactory
|
||||
) {
|
||||
$provider = $em->getReference(ProviderEntity::class, $this->getIdentifier());
|
||||
$this->em = $em;
|
||||
|
||||
$provider = $this->refreshProviderEntity();
|
||||
|
||||
$lines = $lines->withProvider($provider);
|
||||
$stops = $stops->withProvider($provider);
|
||||
@ -117,6 +119,13 @@ class ZtmGdanskProvider implements Provider
|
||||
|
||||
public function getLastUpdate(): ?Carbon
|
||||
{
|
||||
$this->refreshProviderEntity();
|
||||
|
||||
return $this->entity->getUpdateDate();
|
||||
}
|
||||
|
||||
private function refreshProviderEntity(): ProviderEntity
|
||||
{
|
||||
return $this->entity = $this->em->getReference(ProviderEntity::class, $this->getIdentifier());
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class AggregateConverter implements Converter, CacheableConverter
|
||||
return clone $this->cachedConverters;
|
||||
}
|
||||
|
||||
public function flushCache()
|
||||
public function reset()
|
||||
{
|
||||
$this->ensureCachedConverters();
|
||||
|
||||
@ -53,7 +53,7 @@ class AggregateConverter implements Converter, CacheableConverter
|
||||
->cachedConverters
|
||||
->filter(instance(CacheableConverter::class))
|
||||
->each(function (CacheableConverter $converter) {
|
||||
$converter->flushCache();
|
||||
$converter->reset();
|
||||
})
|
||||
;
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
interface CacheableConverter extends Converter
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
interface CacheableConverter extends Converter, ResetInterface
|
||||
{
|
||||
public function flushCache();
|
||||
}
|
||||
|
@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\{Entity, LineEntity, OperatorEntity, StopEntity, TrackEntity, TripEntity, TripStopEntity};
|
||||
use App\Entity\{Entity, LineEntity, OperatorEntity, StopEntity, TrackEntity, TripEntity};
|
||||
use App\Model\{Line, Location, Operator, ScheduledStop, Stop, Track, Trip};
|
||||
use App\Service\Proxy\ReferenceFactory;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Doctrine\ORM\Proxy\Proxy;
|
||||
use Kadet\Functional as f;
|
||||
use Kadet\Functional\Transforms as t;
|
||||
use const Kadet\Functional\_;
|
||||
|
||||
final class EntityConverter implements Converter, RecursiveConverter, CacheableConverter
|
||||
{
|
||||
@ -177,7 +175,7 @@ final class EntityConverter implements Converter, RecursiveConverter, CacheableC
|
||||
return $entity instanceof Entity;
|
||||
}
|
||||
|
||||
public function flushCache()
|
||||
public function reset()
|
||||
{
|
||||
$this->cache = [];
|
||||
}
|
||||
|
39
api/src/Subscriber/RequestCleanupSubscriber.php
Normal file
39
api/src/Subscriber/RequestCleanupSubscriber.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Subscriber;
|
||||
|
||||
use App\Service\Converter;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\TerminateEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
class RequestCleanupSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
/** @var ContainerInterface */
|
||||
private ContainerInterface $container;
|
||||
private Converter $converter;
|
||||
|
||||
public function __construct(ContainerInterface $container, Converter $converter)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->converter = $converter;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
KernelEvents::TERMINATE => ['onTerminate']
|
||||
];
|
||||
}
|
||||
|
||||
public function onTerminate(TerminateEvent $event)
|
||||
{
|
||||
$this->container->get('doctrine')->reset();
|
||||
|
||||
if ($this->converter instanceof ResetInterface) {
|
||||
$this->converter->reset();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +1,6 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
FROM $REGISTRY/cojedzie/base:${BASE_VERSION}-fpm as base
|
||||
|
||||
CMD ["./bin/docker-init.sh", "php-fpm"]
|
||||
|
@ -1,26 +1,10 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
FROM $REGISTRY/cojedzie/base:${BASE_VERSION} as base
|
||||
|
||||
FROM php:7.4-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
COPY --from=spiralscout/roadrunner:1.9.2 /usr/bin/rr /usr/bin/rr
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./bin/docker-init.sh", "rr", "serve"]
|
||||
CMD ["./bin/docker-init.sh", "rr", "serve", "-v"]
|
||||
|
@ -21,8 +21,12 @@ RUN apk add git && \
|
||||
COPY . .
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
RUN composer run-script post-install-cmd
|
||||
|
||||
VOLUME /var/db
|
||||
|
||||
# This image is not meant to be run, just to prepare all required files
|
||||
CMD ["/bin/false"]
|
||||
|
27
build/base/cli.Dockerfile
Normal file
27
build/base/cli.Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
|
||||
FROM php:7.4-cli-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
|
||||
# This image is not meant to be run, just to prepare all required files
|
||||
CMD ["/bin/false"]
|
27
build/base/fpm.Dockerfile
Normal file
27
build/base/fpm.Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
|
||||
# This image is not meant to be run, just to prepare all required files
|
||||
CMD ["/bin/false"]
|
@ -135,20 +135,22 @@ fi
|
||||
|
||||
if [ $BUILD_BASE -eq 1 ]; then
|
||||
build --no-register base $ROOT/api/ || exit 1
|
||||
build --no-register --variant fpm base $ROOT/api/ || exit 1
|
||||
build --no-register --variant cli base $ROOT/api/ || exit 1
|
||||
fi
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
api)
|
||||
build api $ROOT/api/ --variant rr --default || exit 1
|
||||
build api $ROOT/api/ --variant fpm || exit 1
|
||||
build api $BUILD/api/ --variant rr --default || exit 1
|
||||
build api $BUILD/api/ --variant fpm || exit 1
|
||||
;;
|
||||
standalone)
|
||||
build standalone $ROOT/api/ --variant rr --default || exit 1
|
||||
build standalone $BUILD/standalone/ --variant rr --default || exit 1
|
||||
;;
|
||||
worker)
|
||||
build worker $ROOT/api/ || exit 1
|
||||
build worker $BUILD/worker/ || exit 1
|
||||
;;
|
||||
front)
|
||||
build front $ROOT/front/ || exit 1
|
||||
|
@ -3,13 +3,14 @@ ARG REGISTRY=docker.io
|
||||
|
||||
FROM ${REGISTRY}/cojedzie/api:${BASE_VERSION}-rr
|
||||
|
||||
RUN apk add supervisor && \
|
||||
# escape=`
|
||||
RUN apk add supervisor gettext && \
|
||||
{ \
|
||||
echo '[supervisord]'; \
|
||||
echo 'nodaemon=true'; \
|
||||
echo ; \
|
||||
echo '[program:roadrunner]'; \
|
||||
echo 'command=rr serve'; \
|
||||
echo 'command=rr serve -v'; \
|
||||
echo 'startsecs=0'; \
|
||||
echo 'start=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
@ -19,7 +20,7 @@ RUN apk add supervisor && \
|
||||
echo 'stderr_logfile_maxbytes=0'; \
|
||||
echo ; \
|
||||
echo '[program:messenger-consumer]'; \
|
||||
echo 'command=php /var/www/bin/console messenger:consume main -vv --time-limit=86400 --limit=10'; \
|
||||
echo 'command=php /var/www/bin/console messenger:consume $COJEDZIE_WORKER_OPTS $COJEDZIE_WORKER_QUEUES'; \
|
||||
echo 'startsecs=0'; \
|
||||
echo 'start=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
@ -27,6 +28,11 @@ RUN apk add supervisor && \
|
||||
echo 'stderr_logfile=/dev/stderr'; \
|
||||
echo 'stdout_logfile_maxbytes=0'; \
|
||||
echo 'stderr_logfile_maxbytes=0'; \
|
||||
} | tee /etc/supervisord.conf;
|
||||
} | tee /etc/supervisord.conf.tpl;
|
||||
|
||||
CMD ["./bin/docker-init.sh", "supervisord", "-c", "/etc/supervisord.conf"]
|
||||
COPY ./supervisord-init.sh ./bin/
|
||||
|
||||
ENV COJEDZIE_WORKER_QUEUES=main
|
||||
ENV COJEDZIE_WORKER_OPTS="-vv --time-limit=86400 --limit=10 --memory-limit=128M"
|
||||
|
||||
CMD ["./bin/supervisord-init.sh", "supervisord", "-c", "/etc/supervisord.conf"]
|
||||
|
7
build/standalone/supervisord-init.sh
Executable file
7
build/standalone/supervisord-init.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f /etc/supervisord.conf.tpl ]; then
|
||||
envsubst < /etc/supervisord.conf.tpl > /etc/supervisord.conf
|
||||
fi
|
||||
|
||||
exec "$@"
|
@ -1,31 +1,15 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
FROM $REGISTRY/cojedzie/base:${BASE_VERSION}-cli
|
||||
|
||||
FROM php:7.4-cli-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
RUN apk add supervisor && \
|
||||
RUN apk add supervisor gettext && \
|
||||
{ \
|
||||
echo '[supervisord]'; \
|
||||
echo 'nodaemon=true'; \
|
||||
echo ; \
|
||||
echo '[program:messenger-consumer]'; \
|
||||
echo 'command=php /var/www/bin/console messenger:consume main -vv --time-limit=86400 --limit=10'; \
|
||||
echo 'command=php /var/www/bin/console messenger:consume $COJEDZIE_WORKER_OPTS $COJEDZIE_WORKER_QUEUES'; \
|
||||
echo 'startsecs=0'; \
|
||||
echo 'start=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
@ -33,8 +17,11 @@ RUN apk add supervisor && \
|
||||
echo 'stderr_logfile=/dev/stderr'; \
|
||||
echo 'stdout_logfile_maxbytes=0'; \
|
||||
echo 'stderr_logfile_maxbytes=0'; \
|
||||
} | tee /etc/supervisord.conf;
|
||||
} | tee /etc/supervisord.conf.tpl;
|
||||
|
||||
VOLUME /var/db
|
||||
COPY ./supervisord-init.sh ./bin/
|
||||
|
||||
CMD ["supervisord", "-c", "/etc/supervisord.conf"]
|
||||
ENV COJEDZIE_WORKER_QUEUES=main
|
||||
ENV COJEDZIE_WORKER_OPTS="-vv --time-limit=86400 --limit=10 --memory-limit=128M"
|
||||
|
||||
CMD ["./bin/supervisord-init.sh", "supervisord", "-c", "/etc/supervisord.conf"]
|
||||
|
7
build/worker/supervisord-init.sh
Executable file
7
build/worker/supervisord-init.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f /etc/supervisord.conf.tpl ]; then
|
||||
envsubst < /etc/supervisord.conf.tpl > /etc/supervisord.conf
|
||||
fi
|
||||
|
||||
exec "$@"
|
43
docker-compose.rr.yml
Normal file
43
docker-compose.rr.yml
Normal file
@ -0,0 +1,43 @@
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- ./front:/var/www/front:cached
|
||||
- ./api:/var/www/api:cached
|
||||
- .docker-compose/nginx/cojedzie-rr.conf:/etc/nginx/conf.d/cojedzie-rr.conf
|
||||
|
||||
api:
|
||||
build:
|
||||
context: ./api
|
||||
dockerfile: rr.Dockerfile
|
||||
env_file:
|
||||
- .docker-compose/api/.env
|
||||
- api/.env.local
|
||||
environment:
|
||||
- TRUSTED_PROXIES=172.0.0.0/8
|
||||
ports:
|
||||
- 8888:8080
|
||||
volumes:
|
||||
- ./api:/var/www:cached
|
||||
- .docker-compose/api/log.conf:/usr/local/etc/php-fpm.d/zz-log.conf
|
||||
command: ["rr", "serve", "-c", ".rr.yaml"]
|
||||
|
||||
frontend:
|
||||
image: node:15.2.1
|
||||
working_dir: /app
|
||||
environment:
|
||||
- APP_API=http://nginx/api
|
||||
volumes:
|
||||
- ./front:/app
|
||||
command: ["node", "build/server.js"]
|
||||
|
||||
blackfire:
|
||||
image: blackfire/blackfire
|
||||
ports: ["8707"]
|
||||
environment:
|
||||
- BLACKFIRE_SERVER_ID
|
||||
- BLACKFIRE_SERVER_TOKEN
|
3
front/CONTRIBUTING.md
Normal file
3
front/CONTRIBUTING.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Contributing guidelines
|
||||
|
||||
TBD
|
Loading…
Reference in New Issue
Block a user