Skip to content

Commit de91844

Browse files
committed
initial
0 parents  commit de91844

File tree

217 files changed

+23253
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+23253
-0
lines changed

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.git
2+
/.env.local
3+
**/.env.*
4+
**/.app_env*
5+
**/*.log
6+
**/._*
7+
**/.DS_Store
8+
**/.gitignore
9+
**/.gitattributes
10+
**/Thumbs.db
11+
**/*.md
12+
**/.dockerignore
13+
Dockerfile*
14+
docs/
15+
node_modules/
16+
public/build/
17+
public/bundles/
18+
var/
19+
vendor/

.env

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
#
13+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
14+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
15+
16+
###> symfony/framework-bundle ###
17+
APP_ENV=dev
18+
APP_SECRET=3247a721904471e968b39c1652eff071
19+
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
20+
#TRUSTED_HOSTS='^localhost|example\.com$'
21+
###< symfony/framework-bundle ###
22+
23+
###> doctrine/doctrine-bundle ###
24+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
25+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
26+
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
27+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
28+
DATABASE_URL=mysql://dev:dev@127.0.0.1:3316/qb_api?serverVersion=mariadb-10.2.22
29+
###< doctrine/doctrine-bundle ###
30+
31+
###> symfony/mailer ###
32+
MAILER_DSN=smtp://localhost
33+
###< symfony/mailer ###
34+
35+
###> symfony/amazon-mailer ###
36+
# MAILER_DSN=ses://ACCESS_KEY:SECRET_KEY@default?region=eu-west-1
37+
# MAILER_DSN=ses+smtp://ACCESS_KEY:SECRET_KEY@default?region=eu-west-1
38+
###< symfony/amazon-mailer ###
39+
40+
DOMAIN=app.easyquickimport.com
41+
WEBDAV_URL=
42+
WEBDAV_USERNAME=
43+
WEBDAV_PASSWORD=
44+
WEBDAV_PATH=

.env.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='s$cretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999
5+
PANTHER_APP_ENV=panther

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
###> symfony/framework-bundle ###
2+
/.env.local
3+
/.env.local.php
4+
/.env.*.local
5+
/.idea
6+
/config/secrets/prod/prod.decrypt.private.php
7+
/public/bundles/
8+
/var/
9+
/vendor/
10+
###< symfony/framework-bundle ###
11+
12+
###> symfony/phpunit-bridge ###
13+
.phpunit
14+
.phpunit.result.cache
15+
/phpunit.xml
16+
###< symfony/phpunit-bridge ###

.gitlab-ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#ENV variables: https://docs.gitlab.com/ce/ci/variables/
2+
image: karser/docker-compose-ci
3+
4+
stages:
5+
- test
6+
- build
7+
- deploy
8+
9+
before_script:
10+
- docker -v && docker-compose -v
11+
12+
test dev:
13+
stage: test
14+
only:
15+
refs:
16+
- branches
17+
variables:
18+
COMPOSE_PROJECT_NAME: "easyquickimport_test${CI_JOB_ID}"
19+
DOCKER_ENV: test
20+
APP_ENV: test
21+
script:
22+
- cd docker
23+
- bin/copy-env.sh
24+
- bin/build.sh
25+
- docker-compose run --rm php sh -c "bin/run-tests.sh"
26+
after_script:
27+
- cd docker
28+
- docker-compose down --remove-orphans
29+
artifacts:
30+
expire_in: 1 week
31+
when: always
32+
paths:
33+
- var/log
34+
35+
build image:
36+
stage: build
37+
variables:
38+
DOCKER_ENV: prod
39+
APP_ENV: prod
40+
script:
41+
- cd docker
42+
- bin/copy-env.sh
43+
- bin/build.sh
44+
- bin/push.sh
45+
46+
deploy prod:
47+
stage: deploy
48+
environment:
49+
name: easyquickimport-prod
50+
url: https://app.easyquickimport.com/
51+
only:
52+
- tags
53+
- branches
54+
when: manual
55+
variables:
56+
DOCKER_ENV: prod
57+
ENVIRONMENT: prod
58+
APP_ENV: prod
59+
COMPOSE_PROJECT_NAME: easyquickimport
60+
VIRTUAL_HOST: app.easyquickimport.com
61+
DATABASE_HOST: ${HZ4_DB_HOST}
62+
MAILER_DSN: ${PROD_MAILER_DSN}
63+
DATABASE_URL: ${PROD_DATABASE_URL}
64+
# connect to the server
65+
DOCKER_TLS_VERIFY: "1"
66+
DOCKER_HOST: $HZ4_DOCKER_HOST
67+
DOCKER_CERT_PATH: "/tmp/certs"
68+
before_script:
69+
- mkdir -p $DOCKER_CERT_PATH
70+
- echo "$HZ4_CA" > $DOCKER_CERT_PATH/ca.pem
71+
- echo "$HZ4_CLIENT_CERT" > $DOCKER_CERT_PATH/cert.pem
72+
- echo "$HZ4_CLIENT_KEY" > $DOCKER_CERT_PATH/key.pem
73+
- ls -alh $DOCKER_CERT_PATH
74+
- echo ${CI_REGISTRY_PASSWORD} | docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} --password-stdin
75+
script:
76+
- cd docker
77+
- bin/copy-env.sh
78+
- docker-compose config | docker stack deploy --with-registry-auth -c - ${COMPOSE_PROJECT_NAME}
79+
after_script:
80+
- rm -rf $DOCKER_CERT_PATH

Dockerfile

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
ARG PHP_VERSION=7.4
2+
ARG NGINX_VERSION=1.18.0
3+
4+
5+
# "php base" stage
6+
FROM php:${PHP_VERSION}-fpm-alpine AS app_php_base
7+
8+
# persistent / runtime deps
9+
RUN apk add --no-cache \
10+
acl \
11+
bash \
12+
fcgi \
13+
file \
14+
gettext \
15+
git \
16+
freetype \
17+
libjpeg-turbo \
18+
libpng \
19+
nano \
20+
;
21+
22+
ARG APCU_VERSION=5.1.18
23+
RUN set -eux; \
24+
apk add --no-cache --virtual .build-deps \
25+
$PHPIZE_DEPS \
26+
icu-dev \
27+
freetype-dev \
28+
libjpeg-turbo-dev \
29+
libpng-dev \
30+
libzip-dev \
31+
postgresql-dev \
32+
zlib-dev \
33+
; \
34+
\
35+
docker-php-ext-configure zip; \
36+
docker-php-ext-configure gd \
37+
--with-freetype=/usr/include/ \
38+
--with-jpeg=/usr/include/ \
39+
; \
40+
docker-php-ext-install -j$(nproc) \
41+
gd \
42+
intl \
43+
mysqli \
44+
pdo \
45+
pdo_mysql \
46+
zip \
47+
; \
48+
pecl install \
49+
apcu-${APCU_VERSION} \
50+
; \
51+
pecl clear-cache; \
52+
docker-php-ext-enable \
53+
gd \
54+
apcu \
55+
# opcache \
56+
mysqli \
57+
pdo_mysql \
58+
; \
59+
\
60+
runDeps="$( \
61+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
62+
| tr ',' '\n' \
63+
| sort -u \
64+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
65+
)"; \
66+
apk add --no-cache --virtual .api-phpexts-rundeps $runDeps; \
67+
\
68+
apk del .build-deps
69+
70+
COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer
71+
72+
RUN ln -s $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
73+
COPY docker/php/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/app.ini
74+
75+
RUN set -eux; \
76+
{ \
77+
echo '[www]'; \
78+
echo 'ping.path = /ping'; \
79+
echo 'clear_env = no'; \
80+
} | tee /usr/local/etc/php-fpm.d/docker-config.conf
81+
82+
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
83+
ENV COMPOSER_ALLOW_SUPERUSER=1
84+
# install Symfony Flex globally to speed up download of Composer packages (parallelized prefetching)
85+
RUN set -eux; \
86+
composer global require "symfony/flex" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
87+
composer clear-cache
88+
ENV PATH="${PATH}:/root/.composer/vendor/bin"
89+
90+
WORKDIR /var/www/app
91+
92+
# "php prod" stage
93+
FROM app_php_base AS app_php
94+
95+
# prevent the reinstallation of vendors at every changes in the source code
96+
COPY composer.json composer.lock symfony.lock ./
97+
RUN set -eux; \
98+
composer install --prefer-dist --no-dev --no-scripts --no-progress --no-suggest; \
99+
composer clear-cache
100+
101+
# do not use .env files in production
102+
COPY .env ./
103+
RUN composer dump-env prod; \
104+
rm .env
105+
106+
# copy only specifically what we need
107+
COPY bin bin/
108+
COPY config config/
109+
COPY public public/
110+
COPY src src/
111+
COPY templates templates/
112+
COPY translations translations/
113+
114+
RUN set -eux; \
115+
mkdir -p var/cache var/log; \
116+
composer dump-autoload --classmap-authoritative --no-dev; \
117+
composer run-script --no-dev post-install-cmd; \
118+
chmod +x bin/console; sync
119+
VOLUME /var/www/app/var
120+
121+
COPY docker/php/docker-healthcheck.sh /usr/local/bin/docker-healthcheck
122+
RUN chmod +x /usr/local/bin/docker-healthcheck
123+
124+
HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD ["docker-healthcheck"]
125+
126+
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
127+
RUN chmod +x /usr/local/bin/docker-entrypoint
128+
129+
ENTRYPOINT ["docker-entrypoint"]
130+
CMD ["php-fpm"]
131+
132+
133+
# "nginx" stage
134+
# depends on the "php" stage above
135+
FROM nginx:${NGINX_VERSION}-alpine AS app_nginx
136+
137+
ADD ./docker/nginx/nginx.conf /etc/nginx/
138+
COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
139+
140+
WORKDIR /var/www/app/public
141+
142+
COPY --from=app_php /var/www/app/public ./
143+
144+
ARG PUID=1000
145+
ARG PGID=1000
146+
147+
RUN if [[ -z $(getent group ${PGID}) ]] ; then \
148+
addgroup -g ${PGID} www-data; \
149+
else \
150+
addgroup www-data; \
151+
fi; \
152+
adduser -D -u ${PUID} -G www-data www-data

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Dmitrii Poddubnyi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)