forked from JhumanJ/OpnForm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker compose setup (JhumanJ#73)
* Add docker compose setup * Shorten healthcheck interval for faster startup * Add .env file for docker setup. Take changes in composer/package-lock into account. * Add readme entry * JWT force command + readme minor changes * Udpated readme --------- Co-authored-by: Julien Nahum <[email protected]>
- Loading branch information
Showing
6 changed files
with
194 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
POSTGRES_USER="postgres" | ||
POSTGRES_PASSWORD="postgres" | ||
POSTGRES_DB="postgres" | ||
|
||
DB_HOST="database" | ||
DB_DATABASE="postgres" | ||
DB_USERNAME="postgres" | ||
DB_PASSWORD="postgres" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ public/.DS_Store | |
.env.production | ||
.env.staging | ||
_ide_helper.php | ||
|
||
/.make.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
up: down .env .make.composer-install .make.npm-install .make.npm-build .make.artisan-key-generate .make.jwt-secret .make.migrate server | ||
|
||
down: | ||
docker compose down | ||
|
||
clean: | ||
rm ./.make.* | ||
|
||
server: | ||
docker compose up -d server | ||
|
||
logs: | ||
docker compose logs -f server | ||
|
||
.make.composer-install: composer.json composer.lock | ||
docker compose run --rm composer-install | ||
touch $@ | ||
|
||
.make.npm-install: package.json package-lock.json | ||
docker compose run --rm npm-install | ||
touch $@ | ||
|
||
.make.npm-build: | ||
docker compose run --rm npm-build | ||
touch $@ | ||
|
||
.make.artisan-key-generate: | ||
docker compose run --rm php-cli artisan key:generate | ||
touch $@ | ||
|
||
.make.jwt-secret: | ||
docker compose run --rm php-cli artisan jwt:secret --f | ||
touch $@ | ||
|
||
.make.migrate: | ||
docker compose run --rm migrate | ||
touch $@ | ||
|
||
.env: | ||
cp .env.example .env | ||
|
||
.PHONY: up down clean server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
|
||
services: | ||
php-cli: | ||
build: | ||
dockerfile: './php-cli.Dockerfile' | ||
entrypoint: [ 'php' ] | ||
volumes: | ||
- '.:/project' | ||
working_dir: '/project' | ||
user: '1000' | ||
|
||
node-cli: | ||
image: 'node:16' | ||
volumes: | ||
- '.:/project' | ||
working_dir: '/project' | ||
user: '1000' | ||
|
||
composer-cli: | ||
build: | ||
dockerfile: './php-cli.Dockerfile' | ||
entrypoint: [ 'composer' ] | ||
volumes: | ||
- '.:/project' | ||
working_dir: '/project' | ||
user: '1000' | ||
|
||
composer-install: | ||
extends: | ||
service: composer-cli | ||
command: [ 'install' ] | ||
|
||
npm-install: | ||
extends: | ||
service: node-cli | ||
entrypoint: [ 'npm' ] | ||
command: [ 'clean-install' ] | ||
|
||
npm-build: | ||
extends: | ||
service: node-cli | ||
entrypoint: [ 'npm', 'run' ] | ||
command: [ 'build' ] | ||
|
||
database: | ||
image: 'postgres:15' | ||
restart: 'unless-stopped' | ||
env_file: '.env.docker' | ||
healthcheck: | ||
test: [ 'CMD-SHELL', 'pg_isready', '-d', 'postgres' ] | ||
start_period: 5s | ||
interval: 5s | ||
timeout: 10s | ||
retries: 3 | ||
|
||
migrate: | ||
extends: | ||
service: php-cli | ||
depends_on: | ||
database: | ||
condition: service_healthy | ||
env_file: '.env.docker' | ||
command: [ 'artisan', 'migrate' ] | ||
|
||
server: | ||
extends: | ||
service: php-cli | ||
depends_on: | ||
migrate: | ||
condition: service_completed_successfully | ||
env_file: '.env.docker' | ||
command: [ '-S', '0.0.0.0:4000', '-t', './public'] | ||
ports: | ||
- '4000:4000' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# syntax=docker/dockerfile:1.3-labs | ||
FROM php:8.1-cli | ||
|
||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ | ||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer | ||
|
||
RUN <<EOF | ||
install-php-extensions \ | ||
apcu \ | ||
bcmath \ | ||
bz2 \ | ||
calendar \ | ||
ffi \ | ||
gd \ | ||
gmp \ | ||
imagick \ | ||
intl \ | ||
mysqli \ | ||
pcntl \ | ||
pcov \ | ||
pdo_mysql \ | ||
pdo_pgsql \ | ||
redis \ | ||
soap \ | ||
sockets \ | ||
sodium \ | ||
xsl \ | ||
zip \ | ||
exif | ||
EOF |