Skip to content

Commit

Permalink
Merge pull request #2151 from codeeu/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
alainvd committed Oct 5, 2023
2 parents 9edc709 + 7e9a6fc commit aeb9444
Show file tree
Hide file tree
Showing 17 changed files with 669 additions and 170 deletions.
13 changes: 13 additions & 0 deletions app/Http/Controllers/ResourcesPageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ResourcesPageController extends Controller
{
public function index(Request $request)
{
return view('resources-page');
}
}
34 changes: 34 additions & 0 deletions app/View/Components/tailwind/CtaWithImage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\View\Components\tailwind;

use Illuminate\View\Component;

class CtaWithImage extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
public string $imagePosition,
public string $title,
public string $content,


)
{

}

/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.tailwind.cta-with-image');
}
}
187 changes: 187 additions & 0 deletions devspace.yaml
Original file line number Diff line number Diff line change
@@ -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}
36 changes: 36 additions & 0 deletions devspace/.env.devspace
Original file line number Diff line number Diff line change
@@ -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

[email protected]
50 changes: 50 additions & 0 deletions devspace/README.md
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions devspace/codeweek.yaml
Original file line number Diff line number Diff line change
@@ -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

28 changes: 28 additions & 0 deletions devspace/nginx-config-configmap.yaml
Original file line number Diff line number Diff line change
@@ -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; }
}
Loading

0 comments on commit aeb9444

Please sign in to comment.