From c5d4598e1d2d1e3266c7017b5907af1b8e9f22c4 Mon Sep 17 00:00:00 2001 From: Raphael Domingues Date: Thu, 12 Jan 2023 09:10:38 +0100 Subject: [PATCH 1/5] devspace for codeweek --- devspace.yaml | 187 +++++++++++++++++++++++++++ devspace/.env.devspace | 36 ++++++ devspace/README.md | 50 +++++++ devspace/codeweek.yaml | 40 ++++++ devspace/nginx-config-configmap.yaml | 28 ++++ 5 files changed, 341 insertions(+) create mode 100644 devspace.yaml create mode 100644 devspace/.env.devspace create mode 100644 devspace/README.md create mode 100644 devspace/codeweek.yaml create mode 100644 devspace/nginx-config-configmap.yaml diff --git a/devspace.yaml b/devspace.yaml new file mode 100644 index 000000000..c00621394 --- /dev/null +++ b/devspace.yaml @@ -0,0 +1,187 @@ +version: v1beta11 + +vars: + - name: APP_IMAGE + value: public.ecr.aws/cnect-prime/php-8.0-fpm:latest + - name: GITHUB_TOKEN + - name: NOVA_USERNAME + - name: NOVA_PASSWORD + +deployments: + - name: nginx-config + kubectl: + manifests: + - devspace/nginx-config-configmap.yaml + - name: codeweek-config + kubectl: + manifests: + - devspace/codeweek.yaml + - name: mysql + helm: + componentChart: false + chart: + name: mysql + version: 9.4.5 + repo: https://charts.bitnami.com/bitnami + values: + image: + tag: 8.0.31 + resources: + limits: + memory: 2Gi + requests: + cpu: 0.5 + memory: 1Gi + auth: + rootPassword: $!{DB_PASSWORD} + database: $!{DB_DATABASE} + username: $!{DB_USERNAME} + password: $!{DB_PASSWORD} + primary: + startupProbe: + enabled: false + initialDelaySeconds: 90 + livenessProbe: + enabled: false + readinessProbe: + enabled: false + service: + ports: + mysql: ${DB_PORT} + - name: laravel-app + helm: + componentChart: true + values: + containers: + - name: nginx + image: nginx:alpine + volumeMounts: + - containerPath: /etc/nginx/conf.d + volume: + name: nginx-config + readOnly: true + - containerPath: /assets + volume: + name: shared-files + readOnly: true + - name: php + image: ${APP_IMAGE} + imagePullPolicy: Always + resources: + limits: + memory: 2Gi + requests: + cpu: 0.5 + memory: 1Gi + volumeMounts: + - containerPath: /assets + volume: + name: shared-files + readOnly: false + env: + - name: GITHUB_TOKEN + value: ${GITHUB_TOKEN} + - name: NOVA_USERNAME + value: ${NOVA_USERNAME} + - name: NOVA_PASSWORD + value: ${NOVA_PASSWORD} + - name: COMPOSER_ALLOW_SUPERUSER + value: "1" + service: + ports: + - port: 80 + volumes: + - name: nginx-config + configMap: + name: nginx-config + - name: shared-files + emptyDir: { } + - name: redis + helm: + componentChart: false + chart: + name: redis + version: 17.4.0 + repo: https://charts.bitnami.com/bitnami + values: + image: + tag: 6.0.12 + networkPolicy: + enabled: true + allowExternal: true + password: $!{REDIS_PASSWORD} + cluster: + enabled: false +dev: + ports: + - imageSelector: docker.io/bitnami/mysql:8.0.31 + forward: + - port: 3308 + remotePort: 3306 + + sync: + - imageSelector: ${APP_IMAGE} + excludePaths: + - .git/ + - .git/ + - .devspace/ + - README.md + uploadExcludePaths: + - Dockerfile + - devspace.yaml + - deploy/ + - vendor/ + - node_modules/ + onUpload: + execRemote: + onBatch: + command: sh + args: [ "-c", "cp -r /var/www/html/public/* /assets/" ] + exec: + - name: npm-install + command: |- + NODE_ENV=development npm install + onChange: [ "./package.json" ] + - name: composer-install + command: |- + composer install --no-interaction + onChange: [ "./composer.json" ] + +hooks: + - command: | + composer config -g "http-basic.nova.laravel.com" $NOVA_USERNAME $NOVA_PASSWORD + composer config -g github-oauth.github.com $GITHUB_TOKEN + composer update + php artisan key:generate + chmod -R 777 storage + php artisan vue-i18n:generate + NODE_ENV=development npm install + chown -R www-data:www-data /var/www/html; + npm run dev + container: + imageSelector: ${APP_IMAGE} + events: ["after:initialSync:*"] + +commands: + - name: artisan + description: Entry point for artisan commands. + command: devspace enter -c php -- php artisan + appendArgs: true + - name: composer + description: Entry point for composer commands. + command: devspace enter -c php -- composer + appendArgs: true + - name: php + description: Entry point for PHP commands. + command: devspace enter -c php -- php + appendArgs: true + - name: npm + description: Entry point for NPM commands. + command: devspace enter -c php -- npm + appendArgs: true + - name: generate-key + description: Generate APP_KEY. + command: devspace enter -c php -- php artisan key:generate --show + - name: mysql + description: Enter to MySQL shell. + command: devspace enter -c mysql -- mysql -uroot --password=$!{DB_PASSWORD} diff --git a/devspace/.env.devspace b/devspace/.env.devspace new file mode 100644 index 000000000..c90ede77d --- /dev/null +++ b/devspace/.env.devspace @@ -0,0 +1,36 @@ +APP_ENV=local +APP_KEY=base64:R7ErAo+lGcenuwxia/CG4raozxe7lYviGc7gHizfUHw= +APP_DEBUG=true +APP_URL=https://codeweek.local.europa.eu +FORCE_HTTPS=true + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_USERNAME=codeweek +DB_PASSWORD=pass123 +DB_DATABASE=codeweek + +CACHE_DRIVER=file +SESSION_DRIVER=file +QUEUE_DRIVER=sync + +REDIS_HOST=redis-master +REDIS_PORT=6379 + +SCOUT_DRIVER=null +ALGOLIA_APP_ID= +ALGOLIA_KEY= +ALGOLIA_SECRET= + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=eu-west-1 +AWS_BUCKET=codeweek-dev +AWS_URL=https://codeweek-s3.s3.amazonaws.com/ + +LOG_CHANNEL=stack + +LOCALES=al,ba,bg,cs,da,de,el,en,es,et,fi,fr,hr,hu,it,lt,lv,me,mk,nl,pl,pt,ro,rs,sk,sl,sv + +ADMIN_EMAIL=admin@codeweek.test diff --git a/devspace/README.md b/devspace/README.md new file mode 100644 index 000000000..8b75f9305 --- /dev/null +++ b/devspace/README.md @@ -0,0 +1,50 @@ +# Local development with devspace + +[DevSpace](https://www.devspace.sh/) is an open-source developer tool for Kubernetes that lets you develop and deploy cloud-native software faster in your own local. + +The great advantage of use DevSpace is that you don't need all the tools on your local machine, DevSpace will deploy all the containers inside kubernetes keeping the local code development. + +## Pre-Requirements + +- [Rancher Desktop](https://rancherdesktop.io/)(recommended) or [Docker desktop](https://www.docker.com/products/docker-desktop/) + [K3d Cluster](https://k3d.io/) +- [Kubectl](https://kubernetes.io/docs/tasks/tools/) +- [DevSpace CLI](https://www.devspace.sh/) + +## Codeweek installation + +1. In order to run codeweek properly, on your local, you need to have a ssl certificate and simulate a ".europa.eu" domain. For that we need to generate self-signed certificate for your local. +- Follow [this](https://mixable.blog/create-certificate-for-localhost-domains-on-macos/) tutorial to generate self-signed certificates for your localhost +- Create codeweek namespace +```bash +kubectl create ns codeweek +``` +- Create the certificate secret on kubernetes +```bash +kubectl create secret generic certificates-secret --from-file=tls.crt=./localhost.crt --from-file=tls.key=./localhost.key +``` + +2. Add line into the /etc/hosts file +```bash +127.0.0.1 codeweek.local.europa.eu +``` + +3. Copy .env.devspace file +```bash +cp /devpace/.env.devspace .env +``` + +4. After this you can go to the codeweek root directory and type: +```bash +devspace dev +``` + +- Devspace will ask you a token for github and nova credentials +- Wait for devspace starts and setup everything for you + +5. Import and create the database +Create empty database +```bash +devspace run artisan artisan migrate:fresh --seed +``` + +6. Go to https://codeweek.local.europa.eu \ No newline at end of file diff --git a/devspace/codeweek.yaml b/devspace/codeweek.yaml new file mode 100644 index 000000000..941817a18 --- /dev/null +++ b/devspace/codeweek.yaml @@ -0,0 +1,40 @@ +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: security + namespace: codeweek +spec: + headers: + frameDeny: true + sslRedirect: true + browserXssFilter: true + contentTypeNosniff: true + stsIncludeSubdomains: true + stsPreload: true + addVaryHeader: true + stsSeconds: 31536000 + contentSecurityPolicy: upgrade-insecure-requests + customRequestHeaders: + X-Forwarded-Proto: https + +--- + +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: codeweek-ing-route + namespace: codeweek +spec: + entryPoints: + - websecure + routes: + - match: Host(`codeweek.local.europa.eu`) + kind: Rule + services: + - name: laravel-app + port: 80 + middlewares: + - name: security + tls: + secretName: certificates-secret + diff --git a/devspace/nginx-config-configmap.yaml b/devspace/nginx-config-configmap.yaml new file mode 100644 index 000000000..09b689ce0 --- /dev/null +++ b/devspace/nginx-config-configmap.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-config +data: + nginx.conf: |- + server { + listen 80 default_server; + server_name nginx; + root /assets/; + + index index.php; + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + include fastcgi.conf; + fastcgi_pass 127.0.0.1:9000; + fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php; + fastcgi_param PHP_VALUE "memory_limit = 2048M"; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + } From aeaa1f390d6219755fc60b522b100674f54bc913 Mon Sep 17 00:00:00 2001 From: Alain Van Driessche Date: Mon, 8 May 2023 16:44:56 +0200 Subject: [PATCH 2/5] Resources Page with tailwind 3 and responsive design --- .../Controllers/ResourcesPageController.php | 13 ++ resources/lang/en/resources-page.php | 8 ++ resources/lang/en/resources.php | 3 +- resources/views/layout/app.blade.php | 123 ------------------ resources/views/layout/menu.blade.php | 2 +- resources/views/resources-page.blade.php | 105 +++++++++++++++ routes/web.php | 6 +- 7 files changed, 132 insertions(+), 128 deletions(-) create mode 100644 app/Http/Controllers/ResourcesPageController.php create mode 100644 resources/lang/en/resources-page.php delete mode 100644 resources/views/layout/app.blade.php create mode 100644 resources/views/resources-page.blade.php diff --git a/app/Http/Controllers/ResourcesPageController.php b/app/Http/Controllers/ResourcesPageController.php new file mode 100644 index 000000000..a09c41cf0 --- /dev/null +++ b/app/Http/Controllers/ResourcesPageController.php @@ -0,0 +1,13 @@ + 'Resources', + 'title' => 'Training Materials, online courses, teaching and learning resources to help you organise your own Codeweek activity!' + +]; \ No newline at end of file diff --git a/resources/lang/en/resources.php b/resources/lang/en/resources.php index 39892bc42..8ea80343f 100644 --- a/resources/lang/en/resources.php +++ b/resources/lang/en/resources.php @@ -78,7 +78,8 @@ 'Tinkering' => 'Tinkering', 'Unplugged Activities' => 'Unplugged Activities', 'Other' => 'Other' - ] + ], + ] ]; diff --git a/resources/views/layout/app.blade.php b/resources/views/layout/app.blade.php deleted file mode 100644 index 609288a9b..000000000 --- a/resources/views/layout/app.blade.php +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - Listing Hub - Listing & Directory Template | ThemezHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @stack('css') - - - -
- - - @include('include.header') - - @yield('content') - - - - - - - - @include('include.footer') - - - @include('include.login') - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -@stack('scripts') - - - - - - - - - \ No newline at end of file diff --git a/resources/views/layout/menu.blade.php b/resources/views/layout/menu.blade.php index 8aa80fd36..003b77d6d 100644 --- a/resources/views/layout/menu.blade.php +++ b/resources/views/layout/menu.blade.php @@ -18,7 +18,7 @@
  • - @lang('menu.resources') + @lang('menu.resources')