Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS-593 Libs #399

Merged
merged 35 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**/Dockerfile
**/.dockerignore
**/client/build
**/var
**/vendor
**/node_modules
**/.idea
**/.php-cs-fixer.php
**/.php-cs-fixer.cache
**/.php_cs.cache
/infra
/bin
**/.gitignore
**/.github
/doc
/report
/tmp
**/dist
8 changes: 1 addition & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ jobs:
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2

- name: Update libs
if: ${{ inputs.withLibs }}
shell: bash
run: |
bin/update-libs.sh

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
Expand All @@ -51,7 +45,7 @@ jobs:
- name: Build and Push
uses: docker/build-push-action@v4
with:
context: ${{ inputs.context }}
context: ${{ inputs.withLibs && './' || inputs.context }}
file: ${{ inputs.context }}/Dockerfile
target: ${{ inputs.target }}
push: true
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/build_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ jobs:
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2

- name: Update libs
if: ${{ inputs.withLibs }}
shell: bash
run: |
bin/update-libs.sh

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
Expand All @@ -47,7 +41,7 @@ jobs:
- name: Build and Push API PHP
uses: docker/build-push-action@v4
with:
context: ${{ inputs.context }}
context: ${{ inputs.withLibs && './' || inputs.context }}
file: ${{ inputs.context }}/Dockerfile
target: api-php
push: true
Expand All @@ -63,7 +57,7 @@ jobs:
- name: Build and Push API NGINX
uses: docker/build-push-action@v4
with:
context: ${{ inputs.context }}
context: ${{ inputs.withLibs && './' || inputs.context }}
file: ${{ inputs.context }}/Dockerfile
target: api-nginx
push: true
Expand All @@ -78,7 +72,7 @@ jobs:
- name: Build and Push Worker
uses: docker/build-push-action@v4
with:
context: ${{ inputs.context }}
context: ${{ inputs.withLibs && './' || inputs.context }}
file: ${{ inputs.context }}/Dockerfile
target: worker
push: true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/env.local
/.env.local
/tmp
.turbo
.pnpm-store
node_modules
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
17 changes: 17 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
"trailingComma": "es5",
"arrowParens": "avoid",
"bracketSpacing": false,
"quoteProps": "consistent",
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"overrides": [
{
"files": "*.json",
"options": {
"tabWidth": 2
}
}
]
}
2 changes: 0 additions & 2 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ set -e

load-env

$(dirname $0)/update-libs.sh

docker compose -f docker-compose.init.yml build
docker compose build
42 changes: 42 additions & 0 deletions bin/ops/configurator-migrate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -e

function echo_usage() {
echo "Usage:"
echo " $0 <namespace> <migration-name>"
}

if [ -z "$1" ]; then
echo "Missing Kubernetes namespace."
echo_usage
exit 1
fi

if [ -z "$2" ]; then
echo "Missing migration name."
echo_usage
exit 1
fi

if [ -z "$3" ]; then
echo "Missing HELM release."
echo_usage
exit 1
fi

NS="${1}"
MIGRATION_NAME="${2}"
RELEASE_NAME=phrasea
RELEASE_VERSION="${3}"

echo "Migrating..."

helm -n ${NS} get values ${RELEASE_NAME} -o yaml > /tmp/.current-values.yaml

helm pull https://github.com/alchemy-fr/alchemy-helm-charts-repo/releases/download/phrasea-${RELEASE_VERSION}/phrasea-${RELEASE_VERSION}.tgz

echo "Executing migrations..."
helm -n ${NS} upgrade ${RELEASE_NAME} ./phrasea-${RELEASE_VERSION}.tgz \
-f /tmp/.current-values.yaml \
--set "configurator.executeMigration=${MIGRATION_NAME}"
1 change: 1 addition & 0 deletions bin/ops/db/db.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

DATABASES="
auth
databox
expose
uploader
Expand Down
10 changes: 8 additions & 2 deletions bin/ops/export-all-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ kubectl -n $NS wait --for=condition=Ready pod/${POD}

for d in ${DATABASES}; do
DUMP_FILE="${DIR}/${d}.sql"
APP_POD=$(kubectl -n $NS get pod -l tier=${d}-api-php -o jsonpath="{.items[0].metadata.name}") || continue

dpod="$d"
if [ "$dpod" = "upload" ]; then
dpod="uploader"
fi

APP_POD=$(kubectl -n $NS get pod -l tier=${dpod}-api-php -o jsonpath="{.items[0].metadata.name}") || continue
DB_NAME=$(kubectl -n $NS exec ${APP_POD} -- /bin/ash -c 'echo $DB_NAME')
if [ -z "${DB_NAME}" ]; then
DB_NAME="${d}"
Expand All @@ -71,7 +77,7 @@ done
kubectl -n $NS delete pod ${POD} --force 2> /dev/null

echo "Packaging export..."
PACKAGE_NAME="phrasea-${DATE}.tar.gz"
PACKAGE_NAME="phrasea-${NS}-${DATE}.tar.gz"
PACKAGE="$(realpath "${BASE_DIR}/${PACKAGE_NAME}")"
tar -C ${DIR} -czf ${PACKAGE} ${EXPORTED}
rm -r ${DIR}
Expand Down
7 changes: 6 additions & 1 deletion bin/ops/import-all-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ for d in ${DATABASES}; do
continue
fi

APP_POD=$(kubectl -n $NS get pod -l tier=${d}-api-php -o jsonpath="{.items[0].metadata.name}")
dpod="$d"
if [ "$dpod" = "upload" ]; then
dpod="uploader"
fi

APP_POD=$(kubectl -n $NS get pod -l tier=${dpod}-api-php -o jsonpath="{.items[0].metadata.name}")
DB_NAME=$(kubectl -n $NS exec ${APP_POD} -- /bin/ash -c 'echo $DB_NAME')
CONN_ARGS="-U ${DB_USER} --host ${DB_HOST} --port ${DB_PORT} ${DB_NAME}"

Expand Down
35 changes: 0 additions & 35 deletions bin/update-libs.sh

This file was deleted.

10 changes: 0 additions & 10 deletions bin/watch-libs.sh

This file was deleted.

Loading
Loading