Skip to content

Commit 643d001

Browse files
committed
feat: add kubernetes manifests
1 parent c6dc5e3 commit 643d001

File tree

7 files changed

+183
-2
lines changed

7 files changed

+183
-2
lines changed

.github/workflows/docker.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- ".github/workflows/docker.yml"
1010

1111
jobs:
12-
build:
12+
build-website:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout repository
@@ -35,3 +35,30 @@ jobs:
3535
tags: fraguinha/a50passos.com:latest
3636
context: ./src/website
3737
file: ./src/website/Dockerfile
38+
39+
build-assets:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Set up QEMU
46+
uses: docker/setup-qemu-action@v3
47+
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v3
50+
51+
- name: Log in to Docker Hub
52+
uses: docker/login-action@v3
53+
with:
54+
username: ${{ secrets.DOCKER_USERNAME }}
55+
password: ${{ secrets.DOCKER_PASSWORD }}
56+
57+
- name: Build and push Docker image
58+
uses: docker/build-push-action@v5
59+
with:
60+
push: true
61+
platforms: linux/amd64,linux/arm/v7
62+
tags: fraguinha/a50passos-assets:latest
63+
context: .
64+
file: ./src/website/Dockerfile.assets

k8s/ingress.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: a50passos-ingress
5+
namespace: a50passos
6+
annotations:
7+
cert-manager.io/cluster-issuer: letsencrypt
8+
kubernetes.io/ingress.class: traefik
9+
spec:
10+
rules:
11+
- host: a50passos.com
12+
http:
13+
paths:
14+
- backend:
15+
service:
16+
name: website
17+
port:
18+
number: 8080
19+
path: /
20+
pathType: Prefix
21+
- host: www.a50passos.com
22+
http:
23+
paths:
24+
- backend:
25+
service:
26+
name: website
27+
port:
28+
number: 8080
29+
path: /
30+
pathType: Prefix
31+
- host: a50passos.pt
32+
http:
33+
paths:
34+
- backend:
35+
service:
36+
name: website
37+
port:
38+
number: 8080
39+
path: /
40+
pathType: Prefix
41+
- host: www.a50passos.pt
42+
http:
43+
paths:
44+
- backend:
45+
service:
46+
name: website
47+
port:
48+
number: 8080
49+
path: /
50+
pathType: Prefix
51+
tls:
52+
- hosts:
53+
- a50passos.com
54+
- www.a50passos.com
55+
- a50passos.pt
56+
- www.a50passos.pt
57+
secretName: a50passos-tls-secret

k8s/kustomization.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: a50passos
4+
resources:
5+
- namespace.yml
6+
- website.yml
7+
- ingress.yml

k8s/namespace.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: a50passos

k8s/website.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: website
5+
namespace: a50passos
6+
spec:
7+
replicas: 2
8+
selector:
9+
matchLabels:
10+
app: website
11+
template:
12+
metadata:
13+
labels:
14+
app: website
15+
spec:
16+
initContainers:
17+
- name: create-uploads-dir
18+
image: busybox
19+
command: ['sh', '-c', 'mkdir -p /app/dist/public/images/uploads && chmod -R 755 /app/dist/public/images/uploads']
20+
volumeMounts:
21+
- name: images
22+
mountPath: /app/dist/public/images
23+
- name: copy-image-assets
24+
image: fraguinha/a50passos-assets:latest
25+
command: ['sh', '-c', 'cp -r /assets/* /app/dist/public/images/']
26+
volumeMounts:
27+
- name: images
28+
mountPath: /app/dist/public/images
29+
containers:
30+
- name: website
31+
image: fraguinha/a50passos.com:latest
32+
ports:
33+
- containerPort: 8080
34+
env:
35+
- name: PORT
36+
value: "8080"
37+
- name: NODE_ENV
38+
value: "production"
39+
- name: APPNAME
40+
value: "a50passos"
41+
- name: DATABASE
42+
valueFrom:
43+
secretKeyRef:
44+
name: a50passos-secrets
45+
key: DATABASE
46+
- name: SESSION_SECRET
47+
valueFrom:
48+
secretKeyRef:
49+
name: a50passos-secrets
50+
key: SESSION_SECRET
51+
volumeMounts:
52+
- name: images
53+
mountPath: /app/dist/public/images
54+
volumes:
55+
- name: images
56+
persistentVolumeClaim:
57+
claimName: a50passos-images-pvc
58+
---
59+
apiVersion: v1
60+
kind: Service
61+
metadata:
62+
name: website
63+
namespace: a50passos
64+
spec:
65+
selector:
66+
app: website
67+
ports:
68+
- port: 8080
69+
targetPort: 8080
70+
---
71+
apiVersion: v1
72+
kind: PersistentVolumeClaim
73+
metadata:
74+
name: a50passos-images-pvc
75+
namespace: a50passos
76+
spec:
77+
accessModes:
78+
- ReadWriteMany
79+
storageClassName: longhorn
80+
resources:
81+
requests:
82+
storage: 1Gi

src/website/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ RUN npm ci --verbose
1010
COPY . .
1111

1212
RUN npm run deploy
13+
RUN rm -rf /app/dist/public/images
1314

1415
FROM node:22-slim
1516

@@ -19,4 +20,4 @@ COPY --from=builder /app/dist ./dist
1920
COPY --from=builder /app/node_modules ./node_modules
2021
COPY --from=builder /app/package.json .
2122

22-
CMD ["npm", "start"]
23+
CMD ["npm", "start"]

src/website/Dockerfile.assets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM busybox
2+
3+
COPY src/website/src/public/images /assets

0 commit comments

Comments
 (0)