Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Dec 28, 2019
2 parents a170188 + 2531b6a commit ec8625f
Show file tree
Hide file tree
Showing 35 changed files with 2,174 additions and 1,160 deletions.
45 changes: 35 additions & 10 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##################################################
#
# General settings for your component
#
# General settings for your component
#
##################################################

Expand All @@ -18,21 +18,45 @@ APP_VERSION=V.0.1
APP_DEBUG=1
# What is the enviroment type you want to use for local production? (choose between dec,stag,prod, acce or test)
APP_ENV=dev
# We use a build to tag images, this is swithced to the version on master and to env on other branches
# We use a build to tag images, this is swithced to the version on master and to env on other branches
APP_BUILD=dev
# The description for this api
APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'


APP_LOGO=pc.zaakonline.nl
APP_HOME=pc.zaakonline.nl

# The urls on wich this api is available
TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
TRUSTED_HOSTS='^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.nl$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost'
TRUSTED_HOSTS=^(.+\.)?conduction\.nl$|^(.+\.)?vng\.cloud$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.dev$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost

##################################################
# Orgization details
##################################################

# The following details describe your organisations and are used for both certificate creation, nlx (if active) and common-ground.dev

ORGANIZATION_NAME=Conduction
ORGANIZATION_EMAIL_ADDRESS=[email protected]
ORGANIZATION_COUNTRY_NAME=Netherlands
ORGANIZATION_STATE=Noord-Holland
ORGANIZATION_LOCALITY=Amsterdam
ORGANIZATION_UNIT_NAME=Common-Ground

##################################################
# Documentation settings
##################################################

APP_DOMAIN=conduction.nl
# The subdomain for this component (should be www for applications)
APP_SUBDOMAIN=pc
# he domains on wich you want to provide this component, the first wil be used as primary (or common in cert-manger terms)
APP_DOMAINS=["conduction.nl","zaakonline.nl","huwelijksplanner.online","common-ground.dev"]


# The demo enviroment for this component @depracticed
APP_DEMO=pc.zaakonline.nl
# he Repository for this component
APP_REPRO=https://github.com/ConductionNL/Proto-component-commonground

##################################################
Expand All @@ -41,14 +65,15 @@ APP_REPRO=https://github.com/ConductionNL/Proto-component-commonground

CONTAINER_REGISTRY_BASE=docker.io/conduction
CONTAINER_PROJECT_NAME=pc
# The repository for the primary (php) container of this project
CONTAINER_REPRO=https://hub.docker.com/repository/docker/conduction/pc-php

##################################################
# Notifcation settings
##################################################

NOTIFICATION_ENABLED=falsedxfddxf
NOTIFICATION_PROVIDER=sasd
NOTIFICATION_PROVIDER=sasdasd
NOTIFICATION_ENABLED_AUTHORIZATION=sasd

##################################################
Expand Down Expand Up @@ -78,17 +103,17 @@ HEALTH_ENABLED=false
ARCHIVE_ENABLED=false

##################################################
# NLX Setup, read more at https://docs.nlx.io/get-started/#
# NLX Setup, read more at https://docs.nlx.io/get-started/#
##################################################

# Do you want to provide an nlx outway? (option for your component to reach nlx services)
NLX_OUTWAY=true
NLX_OUTWAY=true

# Do you want to provice an nlx inway (option for nlx services to reach your api)
NLX_INWAY=false
NLX_INWAY=false

# NLX Certification Details
NLX_COUNTRY_NAME=Netherlands
NLX_COUNTRY_NAME=Netherlands
NLX_STATE=Noord-Holland
NLX_LOCALITY=Amsterdam
NLX_ORGANIZATION_NAME=Conduction
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Pulling old images, if any
run: docker-compose pull --ignore-pull-failures
- name: Setting APP_NAME
run: |
export NAME=$(grep APP_NAME= .env | cut -d '=' -f2)
Expand Down Expand Up @@ -55,14 +53,21 @@ jobs:
run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV --build-arg APP_BUILD=$APP_BUILD
- name: Run the docker image
run: docker-compose up -d
- name: Taking some sleep
run: sleep 100
- name: Taking some sleep (for containers to come up)
run: sleep 200
- name: Check if all containers are running
run: docker ps
- name: Dumping the logs
run: docker-compose logs
- name: Database Update
run: docker-compose exec -T php bin/console doctrine:schema:update --force
#- name: Taking some more sleep (for database to be updated)
# run: sleep 20
#- name: Database Check
# run: docker-compose exec -T php bin/console doctrine:schema:validate
- name: Security Checks
run: docker-compose exec -T php composer req sensiolabs/security-checker

- name: Chores
run: docker-compose down
- name: Login to DockerHub Registry
Expand Down Expand Up @@ -95,7 +100,7 @@ jobs:
if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true'
run: helm upgrade $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1
- name: Install through helm
if: failure()
if: failure() && (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true'
run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1
- name: Rollout new containers
if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && success()
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# AUTHORS
54 changes: 43 additions & 11 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,19 @@ Now that we've installed both Helm components, we're ready to use helm to instal
## Setting up ingress
We need at least one nginx controller per kubernetes kluster, doh optionally we could set on up on a per namebase basis

helm install stable/nginx-ingress --name loadbalancer --kubeconfig="kubeconfig.yaml"
```CLI
$ helm install stable/nginx-ingress --name loadbalancer --kubeconfig="kubeconfig.yaml"
```

We can check that out with

```CLI
$ kubectl describe ingress pc-dev-ingress -n=kube-system --kubeconfig="kubeconfig.yaml"
```

## Setting up Kubernetes Dashboard
After we installed helm and tiller we can easily use both to install kubernetes dashboard

```CLI
$ helm install stable/kubernetes-dashboard --name dashboard --kubeconfig="kubeconfig.yaml" --namespace="kube-system"
```
Expand All @@ -57,38 +66,61 @@ $ kubectl -n kube-system describe secrets tiller-token-xxxxx --kubeconfig="kube
This should return the token, copy it to somewhere save (just the token not the other returned information) and start up a dashboard connection

```CLI
$kubectl proxy --kubeconfig="kubeconfig.yaml"
$ kubectl proxy --kubeconfig="kubeconfig.yaml"
```

This should proxy our dashboard to helm making it available trough our favorite browser and a simple link
```CLI
http://localhost:8001/api/v1/namespaces/kube-system/services/https:dashboard-kubernetes-dashboard:https/proxy/#!/login
```


## Cert Manager
https://cert-manager.io/docs/installation/kubernetes/

```CLI
$ kubectl apply --validate=false -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.12/deploy/manifests/00-crds.yaml --kubeconfig="kubeconfig.yaml"
$ kubectl create namespace cert-manager --kubeconfig="kubeconfig.yaml"
```

The we need tp deploy the cert manager to our cluster

```CLI
$ helm repo add jetstack https://charts.jetstack.io
$ helm install --name cert-manager --namespace cert-manager --version v0.12.0 \ jetstack/cert-manager --kubeconfig="kubeconfig.yaml"
```

lets check if everything is working

```CLI
$ kubectl get pods --namespace cert-manager --kubeconfig="kubeconfig.yaml"
$ kubectl describe certificate -n dev --kubeconfig="kubeconfig.yaml"
```

## Deploying trough helm
First we always need to update our dependencies
```CLI
$ helm dependency update ./api/helm
```
If you want to create a new instance
```CLI
$ helm install --name pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1,settings.loadbalancerEnabled=true
$ helm install --name pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0,settings.loadbalancerEnabled=true
$ helm install --name pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0,settings.loadbalancerEnabled=true
$ helm install --name pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1
$ helm install --name pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0
$ helm install --name pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0
```

Or update if you want to update an existing one
```CLI
$ helm upgrade pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1,settings.loadbalancerEnabled=true
$ helm upgrade pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0,settings.loadbalancerEnabled=true
$ helm upgrade pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0,settings.loadbalancerEnabled=true
$ helm upgrade pc-dev ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=dev --set settings.env=dev,settings.debug=1
$ helm upgrade pc-stag ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=stag --set settings.env=stag,settings.debug=0
$ helm upgrade pc-prod ./api/helm --kubeconfig="api/helm/kubeconfig.yaml" --namespace=prod --set settings.env=prod,settings.debug=0
```

Or del if you want to delete an existing one
```CLI
$ helm del pc-dev --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=dev"
$ helm del pc-stag --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=stag"
$ helm del pp-prod --purge --kubeconfig="api/helm/kubeconfig.yaml --namespace=prod"
$ helm del pc-dev --purge --kubeconfig="api/helm/kubeconfig.yaml"
$ helm del pc-stag --purge --kubeconfig="api/helm/kubeconfig.yaml"
$ helm del pc-prod --purge --kubeconfig="api/helm/kubeconfig.yaml"
```

Note that you can replace common ground with the namespace that you want to use (normally the name of your component).
Expand Down
1 change: 1 addition & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Roadmap
10 changes: 2 additions & 8 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,9 @@ More information on using data fixtures can be found at the [symfony website](ht
## Sharing your work
A vital part of te common ground community is sharing your work, and telling other people what you are working. This way people can help you with problems that you run into. And keep tabs on any (security) updates that you make to you code. Sounds like a lot of work right?

Wel it actually isn't, there is a specific common ground platform over at common-ground.dev that reads repositories and updates user. So the only thing we need to do is tell this platform that we have started a new common ground repository. And tell it when we have updates ours. We can do all that by simply adding a webhook to our component.
Wel it actually isn't, there is a specific common ground platform over at common-ground.dev that reads repositories and updates user. So the only thing we need to do is tell this platform that we have started a new common ground repository. How do we do that? Simple we use the name common ground (or commonground) in the discription of our repository. common-ground.dev should then pick up our repository within the hour.

When using Github. To set up a webhook, go to the settings page of your repository or organization. From there, click Webhooks, then Add webhook. Use te following settings:
* Payload URL: https://www.common-ground.dev/webhook/github
* Content type: Application/JSON
* Secret: [leave blanck]
* Events: [just the push event]

Now every time you update your repository the commonground dev page will alerted, rescan your repository and do al the appropriate platform actions. It just as easy as that.
Another option that we have is to declare our repository on [publiccode](), to do this you need to copy the publiccode.yaml from the [api/public/schema](api/public/schema]) folder to your root folder (dont forget to redo this every time you make a change to your repository).


Continues integration
Expand Down
10 changes: 7 additions & 3 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RUN set -eux; \
$PHPIZE_DEPS \
icu-dev \
libzip-dev \
libpng-dev \
postgresql-dev \
zlib-dev \
; \
Expand All @@ -40,6 +41,8 @@ RUN set -eux; \
zip \
mysqli \
pdo_mysql \
pcntl \
gd \
; \
pecl install \
apcu-${APCU_VERSION} \
Expand Down Expand Up @@ -80,6 +83,7 @@ ARG APP_ENV=prod

# prevent the reinstallation of vendors at every changes in the source code
COPY composer.json composer.lock symfony.lock ./

RUN set -eux; \
composer install --prefer-dist --no-dev --no-scripts --no-progress --no-suggest; \
composer clear-cache
Expand All @@ -102,6 +106,7 @@ RUN set -eux; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; sync

VOLUME /srv/api/var

COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
Expand All @@ -113,15 +118,14 @@ CMD ["php-fpm"]
# Let update the docs to show the latest chages
# RUN bin/console api:swagger:export --output=/srv/api/public/schema/openapi.yaml --yaml --spec-version=3

RUN bin/console app:publiccode:update --location=/srv/api/public/schema/ --spec-version=0.2

#############################
# "nginx" stage #
#############################
# depends on the "php" stage above, and with an litle bit of help from https://github.com/shiphp/nginx-env
FROM shiphp/nginx-env AS api_platform_nginx

# We use our own more secure and limited config
#ONBUILD ADD docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf

# Due to our config we need a copy of the public folder for serving static content
COPY docker/nginx/conf.d/default.conf.template /etc/nginx/conf.d/default.conf
WORKDIR /srv/api
Expand Down
6 changes: 5 additions & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@
"api-platform/api-pack": "^1.1",
"conduction/commongroundbundle": "dev-master",
"doctrine/doctrine-fixtures-bundle": "^3.2",
"doctrine/rst-parser": "^0.1.0",
"guzzlehttp/guzzle": "^6.3",
"knplabs/knp-markdown-bundle": "^1.8",
"lexik/jwt-authentication-bundle": "^2.6",
"phpdocumentor/reflection-docblock": "^4.3",
"ramsey/uuid": "^3.8",
"ramsey/uuid-doctrine": "^1.5",
"sensio/framework-extra-bundle": "^5.5",
"sensiolabs/security-checker": "^6.0",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/console": "4.3.*",
"symfony/dotenv": "4.3.*",
"symfony/flex": "^1.1",
"symfony/framework-bundle": "4.3.*",
"symfony/mercure-bundle": "*",
"symfony/property-access": "4.4.*",
"symfony/yaml": "4.3.*",
"tbbc/money-bundle": "^3.1",
"webonyx/graphql-php": "^0.13.8"
Expand Down Expand Up @@ -59,7 +63,7 @@
"extra" : {
"symfony" : {
"allow-contrib" : false,
"require" : "4.3.*"
"require" : "4.4.*"
}
},
"scripts": {
Expand Down
Loading

0 comments on commit ec8625f

Please sign in to comment.