Skip to content

Commit d3c054c

Browse files
committed
refactor
1 parent 88e0d2e commit d3c054c

File tree

221 files changed

+261
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+261
-234
lines changed

.docker/.dockerignore

-15
This file was deleted.

.docker/php/docker-entrypoint.sh

+35-11
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,45 @@ fi
88

99
if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/cakephp' ]; then
1010

11+
mkdir -p logs tmp
1112
chown -R cakephp:www-data .
13+
chmod 774 -R .
1214

13-
#if [ "$APP_ENV" = 'prod' ]; then
14-
# composer install --prefer-dist --no-interaction --no-dev
15-
#else
16-
# composer install --prefer-dist --no-interaction
17-
#fi
15+
# The first time volumes are mounted, the project needs to be recreated
16+
if [ ! -f composer.json ]; then
1817

19-
mkdir -p logs tmp/cache/models tmp/cache/models/persistent tmp/sessions tmp/tests
20-
chown -R cakephp:www-data logs tmp
21-
chmod 775 -R logs tmp
22-
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX logs
23-
setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX tmp
24-
#bin/cake cache clear_all
18+
if [ -f .gitkeep ]; then
19+
rm .gitkeep # create project fails if directory is not empty
20+
fi
21+
22+
COMPOSER_MEMORY_LIMIT=-1
23+
composer create-project --prefer-dist --no-interaction cakephp/app:^4.2 .
24+
rm -rf .github
25+
cp config/.env.example config/.env
26+
cp config/app_local.example.php config/app_local.php
27+
mv ../.assets/bootstrap.php config/bootstrap.php
28+
29+
sed -i '/export APP_NAME/c\export APP_NAME="cakephp"' config/.env
30+
31+
salt=$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
32+
sed -i '/export SECURITY_SALT/c\export SECURITY_SALT="'$salt'"' config/.env
33+
34+
touch .gitkeep
2535

36+
composer require mixerapi/mixerapi
37+
bin/cake plugin load MixerApi
38+
bin/cake mixerapi install --auto Y
39+
fi
40+
41+
if [ "$APP_ENV" != 'prod' ]; then
42+
composer install --prefer-dist --no-interaction
43+
fi
44+
45+
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX logs
46+
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX tmp
47+
setfacl -R -m g:nginx:rwX /srv/app
48+
chown -R cakephp:www-data .
49+
chmod 774 -R .
2650
fi
2751

2852
exec docker-php-entrypoint "$@"

.dockerignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
app/vendor/
2+
app/logs/
3+
app/tmp/
4+
app/config/.env
5+
app/config/app_local.php
6+
app/.git
7+
app/.cache
8+
app/.editorconfig
9+
app/.gitattributes
10+
app/.gitignore
11+
app/.gitkeep
12+
app/webroot/swagger.json
13+
app/plugins/AdminApi/webroot/swagger.json

.kube/README.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@
33
This is provided as a starter/example setup. You can run kubernetes locally with an orchestration tool such as
44
[minikube](https://minikube.sigs.k8s.io/docs/) and [kubectl](https://kubernetes.io/docs/tasks/tools/).
55

6+
Starting minikube:
7+
68
```console
79
minikube start
10+
```
11+
12+
Apply configs:
13+
14+
```console
815
kubectl apply -f .kube/namespace.yaml
916
kubectl apply -f .kube/mysql-secret.yaml
1017
kubectl apply -f .kube/php-secret.yaml
1118
kubectl apply -f .kube/.
12-
minikube service nginx-service -n cakephp-docker
19+
```
20+
21+
Get Kubernetes URL:
22+
23+
```console
24+
minikube service nginx-service -n mixerapi-docker
1325
```
1426

1527
## Using local image
@@ -19,9 +31,18 @@ You may find it helpful to work with a local image instead of continually deploy
1931
```console
2032
eval (minikube docker-env)
2133
docker run -d -p 5005:5005 --restart=always --name registry registry:2
22-
docker build . -f .docker/Dockerfile -t localhost:5005/cakephp-docker:4.2-latest
34+
docker build . -f .docker/Dockerfile -t localhost:5005/mixerapidev-demo:latest
35+
docker push localhost:5005/mixerapidev-demo:latest
2336
```
2437

25-
In [php.yaml](php.yaml) change the image to `localhost:5005/cakephp-docker:4.2-latest`.
38+
In [php.yaml](php.yaml.bak) change the image to `localhost:5005/mixerapidev-demo:latest`.
2639

2740
> Source: https://shashanksrivastava.medium.com/how-to-set-up-minikube-to-use-your-local-docker-registry-10a5b564883
41+
42+
Docker build / push commands:
43+
44+
```console
45+
docker build . -t mixerapidev/demo:latest
46+
docker push mixerapidev/demo:latest
47+
```
48+

.kube/mysql-secret.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Secret
33
metadata:
44
name: mysql-secret
5-
namespace: cakephp-docker
5+
namespace: mixerapi-docker
66
type: Opaque
77
data:
88
mysql-root-password: cm9vdA==

.kube/mysql.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: mysql-deployment
5-
namespace: cakephp-docker
5+
namespace: mixerapi-docker
66
labels:
77
app: mysql
88
spec:
@@ -47,7 +47,7 @@ apiVersion: v1
4747
kind: PersistentVolumeClaim
4848
metadata:
4949
name: mysql-pv-claim
50-
namespace: cakephp-docker
50+
namespace: mixerapi-docker
5151
labels:
5252
app: mysql
5353
spec:
@@ -61,7 +61,7 @@ apiVersion: v1
6161
kind: Service
6262
metadata:
6363
name: mysql-service
64-
namespace: cakephp-docker
64+
namespace: mixerapi-docker
6565
spec:
6666
selector:
6767
app: mysql

.kube/namespace.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: v1
22
kind: Namespace
33
metadata:
4-
name: cakephp-docker
4+
name: mixerapi-docker

.kube/nginx.yaml

-79
This file was deleted.

0 commit comments

Comments
 (0)