Skip to content

Commit 66a4955

Browse files
committed
Update and add new features
1 parent c6f5e43 commit 66a4955

27 files changed

+823
-873
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONTAINER_REGISTRY_BASE=quay.io/api-platform

README.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,15 @@ API Platform Demo
44
This a demonstration application for the [API Platform Framework](https://api-platform.com).
55
Try it online at <https://demo.api-platform.com>.
66

7-
Installation (recommended)
8-
==========================
7+
Install
8+
=======
99

10-
```shell
10+
$ git clone https://github.com/api-platform/demo.git
11+
$ docker-compose up
1112

12-
$ git clone https://github.com/api-platform/demo.git
13+
And go to https://localhost.
1314

14-
$ docker-compose up
15-
```
15+
Loading Fixtures
16+
================
1617

17-
And go to https://localhost
18-
19-
Installation (manual)
20-
=====================
21-
22-
```shell
23-
24-
$ git clone https://github.com/api-platform/demo.git
25-
26-
# Create a user and a database in PostgreSQL and enter the credentials into .env
27-
28-
$ composer install
29-
30-
$ php bin/console doctrine:schema:update --force
31-
```
18+
$ docker-compose exec php bin/console hautelook:fixtures:load

api/.env.dist

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This file is a "template" of which env vars need to be defined for your application
2+
# Create environment variables when deploying to production
3+
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4+
5+
###> symfony/framework-bundle ###
6+
APP_ENV=dev
7+
APP_SECRET=!ChangeMe!
8+
TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
9+
TRUSTED_HOSTS=localhost,api
10+
###< symfony/framework-bundle ###
11+
12+
###> doctrine/doctrine-bundle ###
13+
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
14+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
15+
# Configure your db driver and server_version in config/packages/doctrine.yaml
16+
DATABASE_URL=pgsql://api-platform:!ChangeMe!@db/api
17+
###< doctrine/doctrine-bundle ###
18+
19+
###> nelmio/cors-bundle ###
20+
CORS_ALLOW_ORIGIN=^https?://localhost:?[0-9]*$
21+
###< nelmio/cors-bundle ###
22+
23+
VARNISH_URL=http://cache-proxy

api/Dockerfile

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
1-
FROM composer:1.6
2-
FROM php:7.2-fpm-alpine3.7
1+
ARG PHP_VERSION=7.2
2+
ARG ALPINE_VERSION=3.7
3+
FROM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION}
34

4-
RUN apk add --no-cache --virtual .persistent-deps \
5-
git \
6-
icu-libs \
7-
libpq \
8-
zlib
5+
RUN apk add --no-cache \
6+
git
97

10-
ENV APCU_VERSION 5.1.9
8+
ARG APCU_VERSION=5.1.11
119
RUN set -xe \
1210
&& apk add --no-cache --virtual .build-deps \
1311
$PHPIZE_DEPS \
1412
icu-dev \
1513
postgresql-dev \
1614
zlib-dev \
17-
&& docker-php-ext-install \
15+
&& docker-php-ext-install -j$(nproc) \
1816
intl \
1917
pdo_pgsql \
2018
zip \
2119
&& pecl install \
2220
apcu-${APCU_VERSION} \
21+
&& pecl clear-cache \
2322
&& docker-php-ext-enable --ini-name 20-apcu.ini apcu \
2423
&& docker-php-ext-enable --ini-name 05-opcache.ini opcache \
24+
&& runDeps="$( \
25+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
26+
| tr ',' '\n' \
27+
| sort -u \
28+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
29+
)" \
30+
&& apk add --no-cache --virtual .api-phpexts-rundeps $runDeps \
2531
&& apk del .build-deps
2632

27-
COPY --from=0 /usr/bin/composer /usr/bin/composer
33+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
2834
COPY docker/php/php.ini /usr/local/etc/php/php.ini
29-
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
30-
RUN chmod +x /usr/local/bin/docker-entrypoint
35+
36+
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
37+
ENV COMPOSER_ALLOW_SUPERUSER=1
38+
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative \
39+
&& composer clear-cache
40+
ENV PATH="${PATH}:/root/.composer/vendor/bin"
3141

3242
WORKDIR /srv/api
33-
ENTRYPOINT ["docker-entrypoint"]
34-
CMD ["php-fpm"]
3543

36-
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
37-
ENV COMPOSER_ALLOW_SUPERUSER 1
38-
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative
44+
# Build for production
45+
ARG APP_ENV=prod
3946

4047
# Prevent the reinstallation of vendors at every changes in the source code
4148
COPY composer.json composer.lock ./
@@ -44,6 +51,15 @@ RUN composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-pr
4451

4552
COPY . ./
4653

47-
RUN mkdir -p var/cache var/logs var/sessions \
54+
RUN mkdir -p var/cache var/log var/sessions \
4855
&& composer dump-autoload --classmap-authoritative --no-dev \
56+
&& composer run-script --no-dev post-install-cmd \
57+
&& chmod +x bin/console && sync \
4958
&& chown -R www-data var
59+
VOLUME /srv/api/var
60+
61+
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
62+
RUN chmod +x /usr/local/bin/docker-entrypoint
63+
64+
ENTRYPOINT ["docker-entrypoint"]
65+
CMD ["php-fpm"]

api/composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"php": "^7.1.3",
66
"ext-iconv": "*",
77
"api-platform/api-pack": "^1.0",
8-
"api-platform/core": "^2.2@beta",
8+
"api-platform/core": "^2.2",
99
"guzzlehttp/guzzle": "^6.3",
1010
"nelmio/cors-bundle": "^1.5",
1111
"sensiolabs/security-checker": "^4.1",
@@ -21,13 +21,13 @@
2121
"behat/mink": "^1.7",
2222
"behat/mink-browserkit-driver": "^1.3",
2323
"behat/mink-extension": "^2.3",
24-
"behat/symfony2-extension": "^2.1.4@dev",
24+
"behat/symfony2-extension": "^2.1.4",
2525
"behatch/contexts": "^3.0",
2626
"doctrine/data-fixtures": "^1.3",
27-
"hautelook/alice-bundle": "^2.0@beta",
27+
"hautelook/alice-bundle": "^2.0",
2828
"symfony/dotenv": "^4.0",
2929
"symfony/var-dumper": "^4.0",
30-
"theofidry/alice-data-fixtures": "^1.0@rc"
30+
"theofidry/alice-data-fixtures": "^1.0"
3131
},
3232
"config": {
3333
"preferred-install": {
@@ -70,7 +70,6 @@
7070
},
7171
"extra": {
7272
"symfony": {
73-
"id": "01C1CWTW6ZY7WVG0P7FRFVZ00W",
7473
"allow-contrib": false
7574
}
7675
}

0 commit comments

Comments
 (0)