-
Notifications
You must be signed in to change notification settings - Fork 5
Template docker #87
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
base: main
Are you sure you want to change the base?
Template docker #87
Changes from all commits
be226a3
ede3d9d
7a4c367
c26c5f5
36dae39
613a31d
b65df41
130ac26
67ae843
32e9752
ef9ec3a
ec93f23
5191a77
b0145b7
f6ee842
a264bd3
bc1209f
1688e43
6b1b537
c88dd17
7f97fd5
1f94792
8fbb7e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ Backups can be saved **locally** or in **S3 cloud** (AWS, Scaleway, ...). | |
1. [Prerequisites](#prerequisites) | ||
1. [Manual install](#manual-install) | ||
1. [Install using Task](#task-install) | ||
1. [Install using Docker](#docker-install) | ||
1. [Configure the CRON job](#cron) | ||
1. [Use the application](#use-app) | ||
1. [Login](#login) | ||
|
@@ -62,6 +63,20 @@ Requires [Symfony CLI](https://symfony.com/download) and [Task](https://taskfile | |
1. If you want to run Docker containers (currently only for local emails with MailCatcher): `task docker-start` et `task docker-stop` (requires Docker and Docker Compose) | ||
1. To start the server: `task start` (to stop it: `task stop`) | ||
|
||
## Install using Docker <a name="docker-install"></a> | ||
|
||
Requires [Docker](https://docs.docker.com/) to be installed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also required Docker compose IIUC? |
||
|
||
1. `git clone https://github.com/bastien70/dbsaver.git` | ||
1. `chown 1000:1000 /path/ -R` (Make sure permission are well-defined for 1000:1000) | ||
1. `cd dbsaver` | ||
1. `docker compose -f docker-compose.prod.yaml up -d` | ||
1. `docker compose exec php bash` | ||
1. `composer install` (install dependencies) | ||
1. `php bin/console app:regenerate-app-secret ` (regenerate the secret key allowing to hash databases passwords)' | ||
1. `php bin/console d:m:m -n ` (migrate tables) | ||
1. `php bin/console app:make-user ` (create your account) | ||
|
||
## Configure the CRON job <a name="cron"></a> | ||
|
||
Configure the CRON task allows you to activate the verification of backups to be made. **Set it up to run every day**. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
doctrine: | ||
dbal: | ||
url: '%env(resolve:DATABASE_URL)%' | ||
default_connection: default | ||
connections: | ||
default: | ||
driver: '%env(resolve:DB_CONNECTION)%' | ||
host: '%env(resolve:DB_HOST)%' | ||
port: '%env(resolve:DB_PORT)%' | ||
dbname: '%env(resolve:DB_DATABASE)%' | ||
user: '%env(resolve:DB_USERNAME)%' | ||
password: '%env(resolve:DB_PASSWORD)%' | ||
Comment on lines
-3
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything could be on the dbal level instead of explicitly defining a default connection. Also, I'd like to keep the DATABASE_URL environment variable, so every parameter could be resolved in it instead. |
||
|
||
# IMPORTANT: You MUST configure your server version, | ||
# either here or in the DATABASE_URL env var (see .env file) | ||
#server_version: '15' | ||
|
||
profiling_collect_backtrace: '%kernel.debug%' | ||
orm: | ||
auto_generate_proxy_classes: true | ||
enable_lazy_ghost_objects: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
version: '3.8' | ||
|
||
services: | ||
# PHP Service | ||
php: | ||
build: | ||
context: . | ||
dockerfile: docker/php/Dockerfile | ||
container_name: ${APP_SLUG}_php | ||
restart: unless-stopped | ||
environment: | ||
SERVICE_NAME: ${APP_SLUG}_php | ||
SERVICE_TAGS: ${APP_ENV} | ||
working_dir: /var/www | ||
volumes: | ||
- ./:/var/www | ||
- ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini | ||
networks: | ||
- app_network | ||
|
||
# Nginx Service | ||
nginx: | ||
image: nginx:alpine | ||
container_name: ${APP_SLUG}_nginx | ||
restart: unless-stopped | ||
ports: | ||
- "8888:80" | ||
volumes: | ||
- ./:/var/www | ||
- ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf | ||
networks: | ||
- app_network | ||
|
||
# Mariadb Service | ||
database: | ||
image: mariadb:latest | ||
container_name: ${APP_SLUG}_database | ||
restart: unless-stopped | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
MYSQL_DATABASE: ${DB_DATABASE} | ||
MYSQL_USER: ${DB_USERNAME} | ||
MYSQL_PASSWORD: ${DB_PASSWORD} | ||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} | ||
SERVICE_TAGS: ${APP_ENV} | ||
SERVICE_NAME: ${APP_SLUG}_database | ||
volumes: | ||
- ./storage-db:/var/lib/mysql/ | ||
- ./docker/mysql/my.cnf:/etc/mysql/my.cnf | ||
networks: | ||
- app_network | ||
|
||
# Docker Networks | ||
networks: | ||
app_network: | ||
driver: bridge |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,4 @@ services: | |
- '20-21:20-21/tcp' | ||
- '40000-40009:40000-40009/tcp' | ||
volumes: | ||
db_data: | ||
db_data: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[mysqld] | ||
general_log = 1 | ||
general_log_file = /var/lib/mysql/general.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
server { | ||
listen 80 default; | ||
client_max_body_size 308M; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? |
||
error_log /var/log/nginx/error.log; | ||
access_log /var/log/nginx/access.log; | ||
root /var/www/public; | ||
index index.php; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
gzip_static on; | ||
} | ||
|
||
location ~ \.php$ { | ||
fastcgi_pass php:9000; | ||
fastcgi_index index.php; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
fastcgi_buffers 16 16k; | ||
fastcgi_buffer_size 32k; | ||
include fastcgi_params; | ||
} | ||
|
||
location ~ /\.(?!well-known).* { | ||
deny all; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM php:8.2-fpm | ||
|
||
# Copy composer.lock and composer.json | ||
COPY composer.lock composer.json /var/www/ | ||
|
||
# Set working directory | ||
WORKDIR /var/www | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
mariadb-client \ | ||
libpng-dev \ | ||
libjpeg62-turbo-dev \ | ||
libfreetype6-dev \ | ||
libxslt-dev \ | ||
locales \ | ||
jpegoptim optipng pngquant gifsicle \ | ||
git \ | ||
zip | ||
|
||
# Clear cache | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# Install extensions | ||
RUN docker-php-ext-install pdo pdo_mysql xsl intl gd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are xsl & gd really necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, dependencies is realy neccessay for application, else symfony ask install |
||
|
||
# Install composer | ||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
# Add user for symfony application | ||
RUN groupadd -g 1000 www | ||
RUN useradd -u 1000 -ms /bin/bash -g www www | ||
|
||
# Copy existing application directory contents | ||
COPY . /var/www | ||
|
||
# Copy existing application directory permissions | ||
COPY --chown=www:www . /var/www | ||
|
||
# Change current user to www | ||
USER www | ||
|
||
# Expose port 9000 and start php server | ||
EXPOSE 9000 | ||
CMD ["php-fpm"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
date.timezone=Europe/Paris | ||
memory_limit=512M | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The app should run with less RAM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's the memory limit of the application, do you want me to decrease it? |
||
zend_extension=opcache.so | ||
|
||
# http://symfony.com/doc/current/performance.html | ||
opcache.interned_strings_buffer = 16 | ||
opcache.max_accelerated_files = 20000 | ||
opcache.memory_consumption = 256 | ||
realpath_cache_size = 4096K | ||
realpath_cache_ttl = 600 |
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.
Maybe add a "Docker installation guide" :)
Uh oh!
There was an error while loading. Please reload this page.
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.
Perfect I will make a doc to see explain the installation of docker on debian and ubuntu.
What format did you want the guide in?
in the README.md
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.
Just to be sure, I'm talking about the installation via docker of the application and not the installation of Docker in general :) (I think you had understood)
You can put that under "Installation with Task" (or that of the maker).
A very simple trick will do, it's just to signal that they can use Docker. Besides, I'm not a Docker pro. Did you set up something in the docker script to initialize the application for the 1st time, or do you have to run "task install" or "make install" before?
Uh oh!
There was an error while loading. Please reload this page.
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.
We can do the installation of the project via "make install" or "task install" or via docker commands. So I will add the installation process via docker simply. Do you want me to update also the installation with tack to use docker?
The implementation of docker was created using my template where we can find all the information for the installation, which I could implement in this project ;)
Afterwards I could create a docker image for the whole application if the docker stack will suit you.
https://github.com/TheoMeunier/symfony-template
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.
Yes you can add it on the Task file too ;)
Wow, a docker image would be awesome!
I let @jmsche for the end of the review :)