Skip to content

Commit

Permalink
chore: cleanup dev setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplan-michael committed Aug 6, 2024
1 parent c971333 commit 6df785c
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 20 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/.idea/*
/.composer/cache/*
/attachments/*
/backups/*
Expand All @@ -18,3 +17,10 @@
!db_init.sqlite
/backup/*
/uploads/*

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~
57 changes: 48 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
.PHONY: local-dev-postgresql
local-dev-postgresql:
docker-compose --file deploy/dev-postgres/docker-compose.yml up --build -d
sleep 5
docker exec -it $$(docker ps | grep php-fpm | awk '{print $$1}') bash -c "./bin/installl.sh"

.PHONY: down-local-dev-postgresql
down-local-dev-postgresql:
docker-compose --file deploy/dev-postgres/docker-compose.yml down
# Check for docker/podman
DOCKER := $(shell command -v podman 2> /dev/null || command -v docker 2> /dev/null)

# Check for docker-compose/podman-compose
DOCKER_COMPOSE := $(shell command -v podman-compose 2> /dev/null || command -v docker-compose 2> /dev/null)

.PHONY: info
info:
ifeq ($(DOCKER),)
@echo "Neither docker nor podman is installed."
exit 1
else
@echo "Using $(DOCKER)"
endif

ifeq ($(DOCKER_COMPOSE),)
@echo "Neither docker-compose nor podman-compose is installed."
exit 1
else
@echo "Using $(DOCKER_COMPOSE)"
endif

# Start the containers
.PHONY: compose-up
compose-up:
$(DOCKER_COMPOSE) --file deploy/dev/docker-compose.yml up -d

# Stop the containers
.PHONY: compose-down
compose-down:
$(DOCKER_COMPOSE) --file deploy/dev/docker-compose.yml down

# Get container ID
.PHONY: $(FPM_ID)
FPM_ID = $(shell $(DOCKER) ps | grep 'quay.io/kissj/php-ubi' | awk '{print $$1}')

.PHONY: composer-install
composer-install:
$(DOCKER) exec -it -u root $(FPM_ID) sh -c "COMPOSER_ALLOW_SUPERUSER=1 composer install --no-interaction"

.PHONY: migrate
migrate:
$(DOCKER) exec -it -u root $(FPM_ID) sh -c "COMPOSER_ALLOW_SUPERUSER=1 composer phinx:migrate --no-interaction"


dev-up: info compose-up composer-install migrate
dev-down: info compose-down

1 change: 1 addition & 0 deletions deploy/dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.env
2 changes: 1 addition & 1 deletion deploy/dev-postgres/Caddyfile → deploy/dev/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:80 {
:8080 {
root * /var/www/html/public
file_server
php_fastcgi {env.PHPFPM_HOST}:9000
Expand Down
26 changes: 26 additions & 0 deletions deploy/dev/compose.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
BASEPATH="" # app subfolder with leading slash only, eg. "/registration/kissj" - use "" if running on domain root
DEBUG=true
TEMPLATE_CACHE=true
DEFAULT_LOCALE="cs"
GIT_HASH="default"

LOGGER_TARGET="file" # "file" or "stdout" # TODO implement
LOGGER_FILENAME="app.log"
LOGGER_LEVEL='DEBUG' # values defined in RFC 5424 (fe. DEBUG, INFO, ERROR)

MAIL_DSN="smtp://mailhog:1025" # be careful on the encoding of the special symbols - https://symfony.com/doc/current/mailer.html#transport-setup
MAIL_SEND_MAIL_TO_MAIN_RECIPIENT=true # keep true for sending emails

FILE_HANDLER_TYPE="local" # "local" for saving into local filesystem, "s3bucket" for s3bucket
S3_BUCKET=""
S3_KEY=""
S3_SECRET=""
S3_REGION=""
S3_ENDPOINT=""

SENTRY_DSN=""
SENTRY_PROFILING_RATE="0.5" # from 0 to 1

SKAUTIS_APP_ID="kissj"
SKAUTIS_USE_TEST="true"

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
version: "3.3"
name: kissj-app
services:

#database
postgresql:
image: postgres:14-alpine
image: postgres:16-alpine
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"

environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
Expand All @@ -28,14 +26,18 @@ services:
- POSTGRES_DB=kissj
- DATABASE_HOST=postgresql
- DB_TYPE=postgresql
- REDIS_HOST=dragonfly
- REDIS_PASSWORD=dragonfly
- REDIS_PORT=6379
env_file: "compose.env"
volumes:
- ../../:/var/www/html

#Frontend Web Server
caddy:
image: quay.io/kissj/caddy-ubi
ports:
- 80:80
- 8080:8080
depends_on:
- php-fpm
links:
Expand All @@ -44,18 +46,18 @@ services:
environment:
- PHPFPM_HOST=php-fpm
- WEB_HOST=localhost
env_file: "compose.env"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ../../:/var/www/html

#session storage
redis:
image: redis/redis-stack-server
dragonfly:
image: docker.dragonflydb.io/dragonflydb/dragonfly
ports:
- "6379:6379"
environment:
- REDIS_HOST="redis"
- REDIS_HOST_PASSWORD="redis"
- DFLY_requirepass=dragonfly

# debug mail server
mailhog:
Expand Down

0 comments on commit 6df785c

Please sign in to comment.