1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

docker: Set up a configuration for development

This commit is contained in:
herve0742 2023-01-17 18:50:27 +01:00
parent 417bb7a208
commit 3d82a411e0
4 changed files with 111 additions and 0 deletions

20
compose.yaml Normal file
View File

@ -0,0 +1,20 @@
services:
date-backend:
build:
dockerfile: ./docker/dev/DockerFile
context: .
volumes:
- './:/var/www/html/date-poll-api'
ports:
- "8000:8000"
date-db:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=fdsqlrootpassword
- MYSQL_USER=fdsqluser
- MYSQL_PASSWORD=fdsqlpassword
- MYSQL_DATABASE=framadate_api
restart: always
ports:
- "3307:3306"

19
docker/dev/DockerFile Normal file
View File

@ -0,0 +1,19 @@
FROM php:8.1.14
RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | bash && \
apt-get -y update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq unzip libicu-dev symfony-cli && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php --install-dir=/usr/bin --filename="composer" &&\
php -r "unlink('composer-setup.php');"
RUN docker-php-ext-install pdo_mysql
COPY docker/dev/entrypoint.sh /usr/local/bin/entrypoint
WORKDIR /var/www/html/date-poll-api
EXPOSE 8000
ENTRYPOINT ["entrypoint"]

20
docker/dev/entrypoint.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# Set configuration
cp docker/dev/env.local ./.env.local
# composer
composer install
# Await MySQL Container being ready
until php bin/console doctrine:query:sql "SELECT 1;" ; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 1
done
# Run Database migrations
php bin/console doctrine:schema:drop --force
php bin/console doctrine:schema:create
php bin/console doctrine:fixtures:load --no-interaction
# Run server
symfony serve

52
docker/dev/env.local Normal file
View File

@ -0,0 +1,52 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
ADMIN_TOKEN=admintok
APP_SECRET=appsecret
# Base website url, should contain https:// and having no trailing slash. example: BASE_URL=https://framadate.org
BASE_URL=http://localhost
WEBSITE_NAME=Framadate_2
WEBSITE_LOGO=logo.ico
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS='^localhost|example\.com$'
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11"
# IMPORTANT: You MUST also configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=mysql://fdsqluser:fdsqlpassword@date-db:3306/framadate_api
###< doctrine/doctrine-bundle ###
###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
#MAILER_URL=sendmail://YOUR_WEBSITE
MAILER_URL=null://localhost
# set the support email who will answer users in case of emergency
SUPPORT_EMAIL=support-framadate@YOUR_WEBSITE
SPOOL_PATH=/var/www/html/date-poll-api/var/email/spool
###< symfony/swiftmailer-bundle ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###
###> symfony/mailer ###
# MAILER_DSN=smtp://localhost
###< symfony/mailer ###