From f5efbf37864408d7026dfa739e5bb845f43f29e3 Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Sun, 8 Sep 2024 23:14:59 +1000 Subject: [PATCH] Add moew docker tags --- .github/workflows/build-and-deploy.yml | 9 ++++++--- k8s/deployment.yaml | 24 +++++++++++++++++++----- theme/static_src/tailwind.config.js | 11 +++++++++++ url_manager/settings.py | 10 +++------- 4 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 theme/static_src/tailwind.config.js diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 47940b0..7ce5957 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -38,8 +38,11 @@ jobs: with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: |- + ${{ steps.meta.outputs.tags }} + ghcr.io/wahyd4/links:1.0.${{ github.run_number }} + labels: |- + ${{ steps.meta.outputs.labels }} - name: Deploy to Kubernetes uses: wahyd4/kubectl-helm-action@master @@ -48,6 +51,6 @@ jobs: with: args: |- # Update the deployment.yaml with the new image tag - sed -i 's|image: .*|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}|' k8s/deployment.yaml + sed -i 's|image: .*|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:1.0.${{ github.run_number }}|' k8s/deployment.yaml # Apply Kubernetes manifests kubectl apply -n apps -f k8s/deployment.yaml diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 6e268af..898bed2 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -1,3 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: links-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: nfs-client + resources: + requests: + storage: 2Gi +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -17,17 +29,19 @@ spec: tags.datadoghq.com/env: "prod" tags.datadoghq.com/service: "links" spec: - initContainers: - - name: run-migrations - image: "ghcr.io/wahyd4/links:main" - command: ['python', 'manage.py', 'migrate'] - + volumes: + - name: data + persistentVolumeClaim: + claimName: links-pvc containers: - name: links image: "ghcr.io/wahyd4/links:main" securityContext: runAsUser: 1000 imagePullPolicy: Always + volumeMounts: + - name: data + mountPath: /app/data env: - name: DB_HOST value: new-postgres-postgresql.db.svc.cluster.local diff --git a/theme/static_src/tailwind.config.js b/theme/static_src/tailwind.config.js new file mode 100644 index 0000000..809e28a --- /dev/null +++ b/theme/static_src/tailwind.config.js @@ -0,0 +1,11 @@ +module.exports = { + content: [ + '../templates/**/*.html', + '../../templates/**/*.html', + '../../**/templates/**/*.html', + ], + theme: { + extend: {}, + }, + plugins: [], +} diff --git a/url_manager/settings.py b/url_manager/settings.py index 719b2d3..d0e1c88 100644 --- a/url_manager/settings.py +++ b/url_manager/settings.py @@ -22,7 +22,6 @@ ROOT_URLCONF = 'url_manager.urls' MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', - 'whitenoise.middleware.WhiteNoiseMiddleware', # Add this line 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', # Make sure this is here 'django.middleware.common.CommonMiddleware', @@ -66,12 +65,12 @@ DATABASES = { # 静态文件设置 STATIC_URL = '/static/' -STATIC_ROOT = BASE_DIR / 'staticfiles' +STATIC_ROOT = BASE_DIR / 'static' STATICFILES_DIRS = [ - BASE_DIR / "static", - BASE_DIR / "theme" / "static", + BASE_DIR / "static_src", ] + # 默认自动字段类型 DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' @@ -103,6 +102,3 @@ TAILWIND_APP_NAME = 'new_theme' INTERNAL_IPS = [ "127.0.0.1", ] - -# Add this at the end of the file -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'