diff --git a/.github/workflows/build-dockerfile.yml b/.github/workflows/build-dockerfile.yml new file mode 100644 index 00000000..aaf9f2de --- /dev/null +++ b/.github/workflows/build-dockerfile.yml @@ -0,0 +1,39 @@ +# Based on Publish Docker Container by GitHub Actions +name: publish-dockerfile + +on: + push: + branches: [ project-presentations ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: dev + cache-from: type=gha + cache-to: type=gha,mode=max + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - name: Set up kubectl + uses: azure/setup-kubectl@v3 + with: + kubeconfig: ${{ secrets.KUBECONFIG }} + - name: Deploy to Kubernetes + run: kubectl apply -f kubernetes.yaml diff --git a/.github/workflows/github-actions.yml b/.github/workflows/pre-commit.yml similarity index 86% rename from .github/workflows/github-actions.yml rename to .github/workflows/pre-commit.yml index d6f31c3a..0b055067 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/pre-commit.yml @@ -4,6 +4,7 @@ on: pull_request: push: branches: [main] + branches-ignore: [project-presentations] jobs: pre-commit: diff --git a/kubernetes.yaml b/kubernetes.yaml new file mode 100644 index 00000000..1e73834c --- /dev/null +++ b/kubernetes.yaml @@ -0,0 +1,101 @@ +apiVersion: v1 +kind: StorageClass +metadata: + name: local-storage +provisioner: kubernetes.io/no-provisioner +volumeBindingMode: WaitForFirstConsumer + +--- + +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-pv +spec: + capacity: + storage: 2Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: local-storage + hostPath: + path: "/data" + +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: data-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: manual + resources: + requests: + storage: 1Gi + +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: log-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: manual + resources: + requests: + storage: 1Gi + +--- + +apiVersion: v1 +kind: Deployment +metadata: + name: agtern-deployment + labels: + app: agtern +spec: + replicas: 0 + selector: + matchLabels: + app: agtern + template: + metadata: + labels: + app: agtern + spec: + containers: + - name: agtern + image: ghcr.io/agtern:dev + ports: + - containerPort: 8000 + volumeMounts: + - name: data-volume + mountPath: /app/data + - name: log-volume + mountPath: /app/log + volumes: + - name: data-volume + persistentVolumeClaim: + claimName: data-pvc + - name: log-volume + persistentVolumeClaim: + claimName: config-pvc + +--- + +apiVersion: v1 +kind: Service +metadata: + name: agtern-service +spec: + selector: + app: agtern + ports: + - protocol: TCP + port: 80 + targetPort: 8000 + type: LoadBalancer