Add development environment
This commit is contained in:
143
.dev/README.md
Normal file
143
.dev/README.md
Normal file
@@ -0,0 +1,143 @@
|
||||
# InvoiceShelf Development Environment
|
||||
|
||||
This is dockerized development environment that allows developers to easily get started to develop InvoiceShelf.
|
||||
|
||||
This development environment is **NOT MEANT TO BE USED IN PRODUCTION** and is preconfigured with all the needed tools that InvoiceShelf requires for development purposes. It works on Windows, Linux and MacOS.
|
||||
|
||||
For production grade docker image, please refer to [InvoiceShelf/docker](https://github.com/InvoiceShelf/docker) and [InvoiceShelf on DockerHub](https://hub.docker.com/r/invoiceshelf/invoiceshelf).
|
||||
|
||||
## How to set up
|
||||
|
||||
### 1. Hosts configuration
|
||||
|
||||
We use `invoiceshelf.test` domain for local development within this environment and you need to adhere to it.
|
||||
|
||||
For that purpose you need to edit your OS hosts file or DNS server and add the following line to make the local domain name available on your system.
|
||||
|
||||
```
|
||||
127.0.0.1 invoiceshelf.test
|
||||
```
|
||||
|
||||
#### 1.1. Windows
|
||||
|
||||
The hosts file on Windows is located at `C:\Windows\system32\drivers\etc\hosts`.
|
||||
|
||||
You need to launch Notepad as administrator, open the file through **File > Open**, add the line from above and save the file.
|
||||
|
||||
#### 1.2. Linux and MacOS
|
||||
|
||||
The hosts file on Linux and Mac is located at `/etc/hosts`.
|
||||
|
||||
You need to open the file using your favorite editor as sudo/root, add the line from above and save the file.
|
||||
|
||||
### 2. FileSystem configuration (Linux/MacOS Only)
|
||||
|
||||
If you are using Linux or MacOS operating system, you need to make sure that **USERID** and **GRPID** environment variables are always matching your current session user. Those two variables are required to set up the filesystem permissions correctly on Linux and Mac.
|
||||
|
||||
You can run it one time, every time before starting as follows:
|
||||
|
||||
```
|
||||
export USRID=$(id -u) && export GRPID=$(id -g)
|
||||
```
|
||||
|
||||
or you can append this to your .zshrc/.bashrc by running this command in your terminal:
|
||||
|
||||
```
|
||||
grep -qxF 'export USRID=$(id -u) GRPID=$(id -g)' ~/.${SHELL##*/}rc || echo 'export USRID=$(id -u) GRPID=$(id -g)' >> ~/.${SHELL##*/}rc
|
||||
```
|
||||
this will append the `export` line to your rc file and run it on each terminal session.
|
||||
|
||||
### 3. Clone the project
|
||||
|
||||
Clone the InvoiceShelf project directly from origin or swap the git url with your forked url:
|
||||
|
||||
```bash
|
||||
git clone git@github.com:InvoiceShelf/InvoiceShelf.git
|
||||
```
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### 1. Spinning Up
|
||||
|
||||
To **spin up** the environment, run docker compose as follows:
|
||||
|
||||
**Important**: If you are on Linux/MacOS and didn't added the `export` line to your .zshrc/.bashrc file, you need to repeat `step 2` before spining up, otherwise you will face permissions issue.
|
||||
|
||||
```
|
||||
docker compose -f .dev/docker-compose.yml up
|
||||
```
|
||||
|
||||
### 2. Spinning Down
|
||||
|
||||
To **spin down** the environment, run docker compose as follows:
|
||||
|
||||
```
|
||||
docker compose -f .dev/docker-compose.yml down
|
||||
```
|
||||
|
||||
### 2. Working with binaries
|
||||
|
||||
To correctly run `composer`, `artisan`, `pint`, `pest` or other binaries within this project, you must ssh into the container as follows:
|
||||
|
||||
```
|
||||
docker exec -it --user invoiceshelf invoiceshelf-dev-php /bin/bash
|
||||
```
|
||||
|
||||
In the `/home/invoiceshelf/app` directory you can find the application root and run the commands from there.
|
||||
|
||||
## What is included
|
||||
|
||||
### 1. Web Server
|
||||
|
||||
This dockerized environment uses PHP-FPM and NGINX together to serve the website `invoiceshelf.test`
|
||||
|
||||
Both NGINX and PHP-FPM are configured with optimal settings for development. Please don't use this in production.
|
||||
|
||||
### 2. Databases
|
||||
|
||||
This dockerized environment comes with support for all three databases that InvoiceShelf suppots: MySQL, PostgreSQL and SQLite.
|
||||
|
||||
The setup parameters/credentials for each of the supported databases are as follows.
|
||||
|
||||
| | MySQL | PostgreSQL | SQLite |
|
||||
|---|---|---|---|
|
||||
| **DB_USER** | invoiceshelf | invoiceshelf | Not applicable |
|
||||
| **DB_PASS** | invoiceshelf | invoiceshelf | Not applicable |
|
||||
| **DB_NAME** | invoiceshelf | invoiceshelf | /home/invoiceshelf/database/database.sqlite |
|
||||
| **DB_HOST** | db-mysql | db-pgsql | Not applicable |
|
||||
| **DB_PORT** | 3036 | 5432 | Not applicable |
|
||||
|
||||
**Note:** The only required field for SQLite is **DB_NAME**.
|
||||
|
||||
### 3. Adminer
|
||||
|
||||
Adminer is UI tool for viewing the database contents and executing queries.
|
||||
|
||||
It supports MySQL, PostgreSQL, SQLite.
|
||||
|
||||
#### MySQL/PostgresSQL
|
||||
|
||||
To log into the MySQL or PostgresSQL, use the database information specified in the above section (2. Databases)
|
||||
|
||||
#### SQLite
|
||||
|
||||
To log into the SQLite, use the following credentials:
|
||||
|
||||
| KEY | VALUE |
|
||||
|---|---|
|
||||
| **USER** | admin |
|
||||
| **PASS** | admin |
|
||||
| **NAME** | /database.sqlite |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
14
.dev/adminer/Dockerfile
Normal file
14
.dev/adminer/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM adminer:latest
|
||||
|
||||
USER root
|
||||
|
||||
RUN set -x && \
|
||||
apt update && \
|
||||
apt install curl -y && \
|
||||
cd /var/www/html/plugins-enabled && \
|
||||
curl -O https://gist.githubusercontent.com/gdarko/00af6e9a754f09c3f81cd3c606c33311/raw/d5f6a30f00edecf30a5d380340d9dae79a3b7352/login-password-less.php
|
||||
|
||||
USER adminer
|
||||
CMD [ "php", "-S", "[::]:8080", "-t", "/var/www/html" ]
|
||||
|
||||
EXPOSE 8080
|
||||
68
.dev/docker-compose.mysql.yml
Normal file
68
.dev/docker-compose.mysql.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
services:
|
||||
php-fpm:
|
||||
container_name: invoiceshelf-dev-php
|
||||
build:
|
||||
context: .
|
||||
dockerfile: php/Dockerfile
|
||||
args:
|
||||
- UID=${USRID:-1000}
|
||||
- GID=${GRPID:-1000}
|
||||
volumes:
|
||||
- ../:/home/invoiceshelf/app
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
nginx:
|
||||
container_name: invoiceshelf-dev-nginx
|
||||
image: nginx:stable
|
||||
ports:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- ./nginx/conf.d/dev.conf:/etc/nginx/conf.d/dev.conf
|
||||
- ../:/home/invoiceshelf/app
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
db:
|
||||
image: mariadb:10.9
|
||||
container_name: invoiceshelf-dev-mysql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: invoiceshelf
|
||||
MYSQL_DATABASE: invoiceshelf
|
||||
MYSQL_USER: invoiceshelf
|
||||
MYSQL_PASSWORD: invoiceshelf
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- invoiceshelf-dev-mysql:/var/lib/mysql
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
adminer:
|
||||
container_name: invoiceshelf-dev-adminer
|
||||
build:
|
||||
context: .
|
||||
dockerfile: adminer/Dockerfile
|
||||
environment:
|
||||
ADMINER_PLUGINS: tables-filter
|
||||
ADMINER_DESIGN: konya
|
||||
ports:
|
||||
- '8089:8080'
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
mail:
|
||||
container_name: invoiceshelf-dev-mailpit
|
||||
image: axllent/mailpit:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 1025:1025
|
||||
- 8025:8025
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
networks:
|
||||
invoiceshelf-dev:
|
||||
|
||||
volumes:
|
||||
invoiceshelf-dev-mysql:
|
||||
67
.dev/docker-compose.pgsql.yml
Normal file
67
.dev/docker-compose.pgsql.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
services:
|
||||
php-fpm:
|
||||
container_name: invoiceshelf-dev-php
|
||||
build:
|
||||
context: .
|
||||
dockerfile: php/Dockerfile
|
||||
args:
|
||||
- UID=${USRID:-1000}
|
||||
- GID=${GRPID:-1000}
|
||||
volumes:
|
||||
- ../:/home/invoiceshelf/app
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
nginx:
|
||||
container_name: invoiceshelf-dev-nginx
|
||||
image: nginx:stable
|
||||
ports:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- ./nginx/conf.d/dev.conf:/etc/nginx/conf.d/dev.conf
|
||||
- ../:/home/invoiceshelf/app
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
db:
|
||||
image: postgres:15
|
||||
container_name: invoiceshelf-dev-pgsql
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=invoiceshelf
|
||||
- POSTGRES_USER=invoiceshelf
|
||||
- POSTGRES_DB=invoiceshelf
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- invoiceshelf-dev-pgsql:/var/lib/postgresql/data
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
adminer:
|
||||
container_name: invoiceshelf-dev-adminer
|
||||
build:
|
||||
context: .
|
||||
dockerfile: adminer/Dockerfile
|
||||
environment:
|
||||
ADMINER_PLUGINS: tables-filter
|
||||
ADMINER_DESIGN: konya
|
||||
ports:
|
||||
- '54320:8080'
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
mail:
|
||||
container_name: invoiceshelf-dev-mailpit
|
||||
image: axllent/mailpit:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 1025:1025
|
||||
- 8025:8025
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
networks:
|
||||
invoiceshelf-dev:
|
||||
|
||||
volumes:
|
||||
invoiceshelf-dev-pgsql:
|
||||
52
.dev/docker-compose.yml
Normal file
52
.dev/docker-compose.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
services:
|
||||
php-fpm:
|
||||
container_name: invoiceshelf-dev-php
|
||||
build:
|
||||
context: .
|
||||
dockerfile: php/Dockerfile
|
||||
args:
|
||||
- UID=${USRID:-1000}
|
||||
- GID=${GRPID:-1000}
|
||||
volumes:
|
||||
- ../:/home/invoiceshelf/app
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
nginx:
|
||||
container_name: invoiceshelf-dev-nginx
|
||||
image: nginx:stable
|
||||
ports:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- ./nginx/conf.d/dev.conf:/etc/nginx/conf.d/dev.conf
|
||||
- ../:/home/invoiceshelf/app
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
adminer:
|
||||
container_name: invoiceshelf-dev-adminer
|
||||
build:
|
||||
context: .
|
||||
dockerfile: adminer/Dockerfile
|
||||
environment:
|
||||
ADMINER_PLUGINS: tables-filter
|
||||
ADMINER_DESIGN: konya
|
||||
volumes:
|
||||
- ../database/database.sqlite:/database.sqlite
|
||||
ports:
|
||||
- '54320:8080'
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
mail:
|
||||
container_name: invoiceshelf-dev-mailpit
|
||||
image: axllent/mailpit:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 1025:1025
|
||||
- 8025:8025
|
||||
networks:
|
||||
- invoiceshelf-dev
|
||||
|
||||
networks:
|
||||
invoiceshelf-dev:
|
||||
22
.dev/nginx/conf.d/dev.conf
Normal file
22
.dev/nginx/conf.d/dev.conf
Normal file
@@ -0,0 +1,22 @@
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
root /home/invoiceshelf/app/public;
|
||||
index index.php;
|
||||
|
||||
error_log /var/log/nginx/dev-error.log;
|
||||
access_log /var/log/nginx/dev-access.log;
|
||||
|
||||
server_name invoiceshelf.test;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php-fpm:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
60
.dev/php/Dockerfile
Normal file
60
.dev/php/Dockerfile
Normal file
@@ -0,0 +1,60 @@
|
||||
FROM php:8.3-fpm-bookworm
|
||||
|
||||
ARG UID
|
||||
ARG GID
|
||||
|
||||
ENV UID=${UID}
|
||||
ENV GID=${GID}
|
||||
|
||||
USER root
|
||||
|
||||
# Create user/group
|
||||
RUN addgroup --gid ${GID} --system invoiceshelf && \
|
||||
adduser --gid ${GID} --system --disabled-password --shell /bin/sh -u ${UID} --home /home/invoiceshelf invoiceshelf && \
|
||||
sed -i "s/user = www-data/user = invoiceshelf/g" /usr/local/etc/php-fpm.d/www.conf && \
|
||||
sed -i "s/group = www-data/group = invoiceshelf/g" /usr/local/etc/php-fpm.d/www.conf
|
||||
|
||||
# Install Composer
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# install dependencies
|
||||
RUN apt update && apt install -y \
|
||||
libpng-dev \
|
||||
zlib1g-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev \
|
||||
libonig-dev \
|
||||
libpq-dev \
|
||||
sqlite3 \
|
||||
postgresql-client \
|
||||
mariadb-client \
|
||||
zip \
|
||||
curl \
|
||||
unzip \
|
||||
webp \
|
||||
&& docker-php-ext-configure gd \
|
||||
&& docker-php-ext-install -j$(nproc) gd \
|
||||
&& docker-php-ext-install bcmath \
|
||||
&& docker-php-ext-install mbstring \
|
||||
&& docker-php-ext-install mysqli \
|
||||
&& docker-php-ext-install pdo_mysql \
|
||||
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
|
||||
&& docker-php-ext-install pgsql \
|
||||
&& docker-php-ext-install pdo_pgsql \
|
||||
&& docker-php-ext-install zip \
|
||||
&& docker-php-ext-install xml \
|
||||
&& docker-php-source delete
|
||||
|
||||
# Clear cache
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set workdir
|
||||
WORKDIR /home/invoiceshelf/app
|
||||
|
||||
# Copy Files
|
||||
COPY /php/entrypoint.sh /
|
||||
|
||||
# Entrypoint
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
CMD ["php-fpm"]
|
||||
12
.dev/php/entrypoint.sh
Executable file
12
.dev/php/entrypoint.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "############################################"
|
||||
echo "### InvoiceShelf Development Environment ###"
|
||||
echo "############################################"
|
||||
|
||||
chown -R ${UID}:${GID} /home/invoiceshelf/app
|
||||
chmod +x /home/invoiceshelf/app/artisan
|
||||
|
||||
cd /home/invoiceshelf/app && php artisan storage:link
|
||||
|
||||
exec $@
|
||||
1974
.dev/php/php.ini
Normal file
1974
.dev/php/php.ini
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user