Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Change docker config, take same as api-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeKESTEMAN committed Aug 12, 2022
1 parent 28d4c99 commit e86b421
Show file tree
Hide file tree
Showing 50 changed files with 1,109 additions and 273 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Pull images
run: docker-compose pull
run: docker-compose pull --ignore-pull-failures || true
- name: Start services
run: docker-compose up --build -d
- name: Wait for services
Expand Down
101 changes: 57 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,86 +14,99 @@ generateTestsDB = docker-compose exec php bin/console --env=test doctrine:databa
docker-compose exec php bin/console --env=test doctrine:migrations:migrate --no-interaction;
### test database ###

help:
@echo "MAKEFILE HELP :"
@echo "\t - help: list all makefile commands"
@echo "\t - start: start docker's containers, execute database migrations, execute fixtures, show docker's logs and stop docker containers on terminate signal"
@echo "\t - start-all: start docker's containers, execute database migrations, execute fixtures and show docker's logs"
@echo "\t - stop: stop docker containers"
@echo "\t - install: make a docker build"
@echo "\t - kill-docker-builds: stop, kill and down docker's containers (remove JWT keys)"
@echo "\t - new-db: make a new database with the new migrations"
@echo "\t - jwt-keypair: regenerate JWT keys"
@echo "\t - tests: launch all tests"
@echo "\t - tests-security: launch security tests"
@echo "\t - tests-api: launch api tests"
@echo "\t - fixtures: launch fixtures"
@echo "\t - fixtures-test: launch fixtures for tests"

start:
bash -c "trap 'trap - SIGINT SIGTERM ERR; $(MAKE) stop-all; exit 1' SIGINT SIGTERM ERR; $(MAKE) start-all"
@bash -c "trap 'trap - SIGINT SIGTERM ERR; $(MAKE) stop-all; exit 1' SIGINT SIGTERM ERR; $(MAKE) start-all"

start-all:
docker-compose up -d
docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
docker-compose exec php bin/console hautelook:fixtures:load --no-interaction
sleep 5
cd admin/ && yarn start
@docker-compose up -d
@docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
@docker-compose exec php bin/console hautelook:fixtures:load --no-interaction
@docker-compose logs -f

stop-all:
docker-compose stop
@docker-compose stop

install:
docker-compose build --pull --no-cache
cp -R -n api/.env api/.env.local
cd admin/ && yarn install
@docker-compose build --pull --no-cache
@cp -R -n api/.env api/.env.local

kill-docker-builds:
docker-compose stop
docker-compose kill
docker-compose down --volumes --remove-orphans
rmdir api/config/jwt
@docker-compose stop
@docker-compose kill
@docker-compose down --volumes --remove-orphans
@rmdir api/config/jwt

new-db:
ifeq ($(shell docker-compose ps | wc -l),2)
docker-compose up -d
$(generateDB)
docker-compose stop
@docker-compose up -d
@$(generateDB)
@docker-compose stop
else
$(generateDB)
@$(generateDB)
endif

jwt-keypair:
ifeq ($(shell docker-compose ps | wc -l),2)
docker-compose up -d
$(generateJWT)
docker-compose stop
@docker-compose up -d
@$(generateJWT)
@docker-compose stop
else
$(generateJWT)
@$(generateJWT)
endif

tests:
ifeq ($(shell docker-compose ps | wc -l),2)
docker-compose up -d
bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; $(MAKE) tests-security"
bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; $(MAKE) tests-api"
docker-compose stop
@docker-compose up -d
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; $(MAKE) tests-security"
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; $(MAKE) tests-api"
@docker-compose stop
else
$(MAKE) tests-security
$(MAKE) tests-api
@$(MAKE) tests-security
@$(MAKE) tests-api
endif

tests-security:
ifeq ($(shell docker-compose ps | wc -l),2)
docker-compose up -d
bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit tests/Security"
docker-compose stop
@docker-compose up -d
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit tests/Security"
@docker-compose stop
else
docker-compose exec php bin/phpunit tests/Security
@docker-compose exec php bin/phpunit tests/Security
endif

tests-api:
ifeq ($(shell docker-compose ps | wc -l),2)
docker-compose up -d
$(generateTestsDB)
docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit tests/Api"
docker-compose stop
@docker-compose up -d
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit tests/Api"
@docker-compose stop
else
$(generateTestsDB)
docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
docker-compose exec php bin/phpunit tests/Api
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@docker-compose exec php bin/phpunit tests/Api
endif

fixtures:
docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
docker-compose exec php bin/console hautelook:fixtures:load --no-interaction --purge-with-truncate
@docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
@docker-compose exec php bin/console hautelook:fixtures:load --no-interaction --purge-with-truncate

fixtures-test:
docker-compose exec php bin/console --env=test doctrine:migrations:migrate --no-interaction
docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction --purge-with-truncate
@docker-compose exec php bin/console --env=test doctrine:migrations:migrate --no-interaction
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction --purge-with-truncate
21 changes: 21 additions & 0 deletions admin/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**/*.log
**/*.md
**/._*
**/.dockerignore
**/.DS_Store
**/.git/
**/.gitattributes
**/.gitignore
**/.gitmodules
**/docker-compose.*.yaml
**/docker-compose.*.yml
**/docker-compose.yaml
**/docker-compose.yml
**/Dockerfile
**/Thumbs.db
.next/
build/
node_modules/
.editorconfig
.env.*.local
.env.local
42 changes: 42 additions & 0 deletions admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
# https://docs.docker.com/compose/compose-file/#target

# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG NODE_VERSION=16

# "common" stage
FROM node:${NODE_VERSION}-alpine AS app_admin_common

EXPOSE 3000

WORKDIR /usr/src/admin

ENV NEXT_TELEMETRY_DISABLED 1

# prevent the reinstallation of node modules at every changes in the source code
COPY package.json yarn.lock ./
RUN yarn

COPY . .

VOLUME /usr/src/admin/node_modules

# "development" stage
# depends on the "common" stage above
FROM app_admin_common AS app_admin_dev

VOLUME /usr/src/admin/build

CMD ["yarn", "start"]

# "build" stage
# depends on the "common" stage above
FROM app_admin_common AS app_admin_prod

ENV NODE_ENV production
ARG NEXT_PUBLIC_ENTRYPOINT

RUN set -eux; \
yarn build

CMD ["yarn", "start"]
2 changes: 1 addition & 1 deletion admin/src/config/components/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const API_ENTRYPOINT = 'https://localhost/api';
export const API_ENTRYPOINT = 'https://localhost';
export const ENTRYPOINT = 'https://localhost';
18 changes: 10 additions & 8 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**/*.log
**/*.md
**/*.php~
**/*.dist.php
**/*.dist
**/*.cache
**/._*
**/.dockerignore
**/.DS_Store
Expand All @@ -14,15 +17,14 @@
**/docker-compose.yml
**/Dockerfile
**/Thumbs.db
.github/
docs/
public/bundles/
tests/
var/
vendor/
.editorconfig
.env.*.local
.env.local
.env.local.php
.php_cs.cache
bin/*
!bin/console
docker/db/data/
helm/
public/bundles/
var/
vendor/
.env.test.local
10 changes: 7 additions & 3 deletions api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

# API Platform distribution
TRUSTED_PROXIES=127.0.0.1
TRUSTED_HOSTS=^localhost$

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=f7b55e955f22606e526aa47daba087e6
APP_SECRET=!ChangeMe!
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
Expand All @@ -25,7 +29,7 @@ APP_SECRET=f7b55e955f22606e526aa47daba087e6
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7&charset=utf8mb4"
DATABASE_URL="postgresql://symfony:[email protected]:5432/app?serverVersion=13&charset=utf8"
DATABASE_URL="postgresql://symfony:[email protected]:5432/api?serverVersion=14&charset=utf8"
###< doctrine/doctrine-bundle ###

###> lexik/jwt-authentication-bundle ###
Expand Down Expand Up @@ -82,7 +86,7 @@ USER_IN_MEMORY_HASHED_PASSWORD='USER_IN_MEMORY_HASHED_PASSWORD'
# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
MERCURE_URL=https://example.com/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=https://example.com/.well-known/mercure
MERCURE_PUBLIC_URL=https://localhost/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET="!ChangeMe!"
###< symfony/mercure-bundle ###
Expand Down
3 changes: 3 additions & 0 deletions api/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots

# API Platform distribution
TRUSTED_HOSTS=^example\.com|localhost$

###< secrity-user_in_memory ###
USER_IN_MEMORY_USERNAME=admin
USER_IN_MEMORY_PASSWORD=admin
Expand Down
Loading

0 comments on commit e86b421

Please sign in to comment.