apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: forgejo-data-pvc
  namespace: forgejo
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: forgejo
  namespace: forgejo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: forgejo
  template:
    metadata:
      labels:
        app: forgejo
    spec:
      containers:
        - name: forgejo
          image: codeberg.org/forgejo/forgejo:11
          env:
            - name: USER_UID
              value: "1000"
            - name: USER_GID
              value: "1000"
          ports:
            - containerPort: 3000
            - containerPort: 22
          volumeMounts:
            - name: forgejo-data
              mountPath: /data
            - name: timezone
              mountPath: /etc/timezone
              readOnly: true
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
      volumes:
        - name: forgejo-data
          persistentVolumeClaim:
            claimName: forgejo-data-pvc
        - name: timezone
          hostPath:
            path: /etc/timezone
        - name: localtime
          hostPath:
            path: /etc/localtime
---
apiVersion: v1
kind: Service
metadata:
  name: forgejo
  namespace: forgejo
spec:
  type: NodePort
  selector:
    app: forgejo
  ports:
    - name: http
      port: 3000
      targetPort: 3000
    - name: ssh
      port: 22
      targetPort: 22
      nodePort: 30022
