Skip to content

Commit c891d07

Browse files
committed
Add hosts/ports and ECR registry to image build
1 parent 46963a4 commit c891d07

4 files changed

Lines changed: 65 additions & 45 deletions

File tree

.diploi/helm/app-ingress.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@ metadata:
55
annotations:
66
kubernetes.io/ingress.class: traefik
77
spec:
8+
{{- if .Values.endpoints }}
89
tls:
910
- hosts:
10-
- {{ .Values.hosts.app }}
11+
{{- range .Values.endpoints }}
12+
- {{ .url }}
13+
{{- end }}
1114
secretName: tls-secret
1215
rules:
13-
- host: {{ .Values.hosts.app }}
16+
{{- range .Values.endpoints }}
17+
- host: {{ .url }}
1418
http:
1519
paths:
1620
- path: '/'
1721
pathType: Prefix
1822
backend:
1923
service:
20-
name: app
24+
name: {{ .serviceName }}
2125
port:
22-
number: 8000
26+
number: {{ .port }}
27+
{{- end }}
28+
{{- end }}

.diploi/helm/app-service.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ kind: Service
33
metadata:
44
name: app
55
spec:
6+
{{- if .Values.ports }}
67
ports:
7-
- port: 8000
8-
name: app
8+
{{- range .Values.ports }}
9+
{{- if eq .serviceName "app" }}
10+
- port: {{ .port }}
11+
name: {{ .identifier }}
12+
{{- end }}
13+
{{- end }}
14+
{{- end }}
915
selector:
10-
app: app
16+
app: app

.github/workflows/Prebuild.yaml

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
1-
name: Pre-Build
1+
name: Pre-Build Components
22

33
on:
44
push:
55

66
env:
7-
REGISTRY: ghcr.io
7+
REGISTRY: public.ecr.aws
8+
PROJECT: p8t2q7f4/${{ github.repository }}
9+
10+
permissions:
11+
id-token: write
12+
contents: read
813

914
jobs:
1015
production:
11-
name: "Production"
16+
name: 'Production'
1217
runs-on: ubuntu-24.04-arm
13-
permissions:
14-
packages: write
18+
1519
steps:
16-
- name: Set up QEMU
17-
uses: docker/setup-qemu-action@v3
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Configure AWS credentials (OIDC)
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
role-to-assume: arn:aws:iam::300197899440:role/ECRPrebuildPushRightsForGithubActionsRole
27+
aws-region: us-east-1
1828

19-
- name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v3
29+
- name: Login to Amazon ECR Public
30+
id: login-ecr-public
31+
uses: aws-actions/amazon-ecr-login@v2
32+
with:
33+
registry-type: public
2134

2235
- name: Docker meta
2336
id: meta
2437
uses: docker/metadata-action@v4
2538
with:
26-
images: ${{ env.REGISTRY }}/${{ github.repository }}
39+
images: ${{ env.REGISTRY }}/${{ env.PROJECT }}
2740
tags: |
2841
type=ref,event=branch
2942
type=ref,event=tag
3043
# Set latest tag for default branch
3144
type=raw,value=latest,enable={{is_default_branch}}
3245
33-
- name: "Login to GitHub Container Registry"
34-
uses: docker/login-action@v3
35-
with:
36-
registry: ${{ env.REGISTRY }}
37-
username: ${{ github.actor }}
38-
password: ${{ secrets.GITHUB_TOKEN }}
39-
4046
- name: Build and push
4147
uses: docker/build-push-action@v6
4248
with:
@@ -46,42 +52,42 @@ jobs:
4652
labels: ${{ steps.meta.outputs.labels }}
4753

4854
development:
49-
name: "Development"
50-
runs-on: ubuntu-latest
51-
permissions:
52-
packages: write
53-
steps:
54-
- name: Set up QEMU
55-
uses: docker/setup-qemu-action@v3
55+
name: 'Development'
56+
runs-on: ubuntu-24.04-arm
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v3
60+
61+
- name: Configure AWS credentials (OIDC)
62+
uses: aws-actions/configure-aws-credentials@v4
63+
with:
64+
role-to-assume: arn:aws:iam::300197899440:role/ECRPrebuildPushRightsForGithubActionsRole
65+
aws-region: us-east-1
5666

57-
- name: Set up Docker Buildx
58-
uses: docker/setup-buildx-action@v3
67+
- name: Login to Amazon ECR Public
68+
id: login-ecr-public
69+
uses: aws-actions/amazon-ecr-login@v2
70+
with:
71+
registry-type: public
5972

6073
- name: Docker meta
6174
id: meta
6275
uses: docker/metadata-action@v4
6376
with:
64-
images: ${{ env.REGISTRY }}/${{ github.repository }}
77+
images: ${{ env.REGISTRY }}/${{ env.PROJECT }}
6578
tags: |
6679
type=ref,event=branch
6780
type=ref,event=tag
6881
# Set latest tag for default branch
6982
type=raw,value=latest,enable={{is_default_branch}}
7083
flavor: |
7184
suffix=-dev.,onlatest=true
72-
73-
- name: "Login to GitHub Container Registry"
74-
uses: docker/login-action@v3
75-
with:
76-
registry: ${{ env.REGISTRY }}
77-
username: ${{ github.actor }}
78-
password: ${{ secrets.GITHUB_TOKEN }}
79-
85+
8086
- name: Build and push
8187
uses: docker/build-push-action@v6
8288
with:
8389
file: Dockerfile.dev
8490
push: ${{ github.event_name != 'pull_request' }}
8591
platforms: linux/arm64
8692
tags: ${{ steps.meta.outputs.tags }}
87-
labels: ${{ steps.meta.outputs.labels }}
93+
labels: ${{ steps.meta.outputs.labels }}

diploi.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ type: component
33
name: Python
44
description: Official Python component for Diploi
55

6+
supportsAdditionalHosts: { serviceName: 'app'}
7+
68
hosts:
79
- name: Python
810
identifier: app
9-
urlFormat: '[label].[default-domain]'
11+
port: 8000
1012

1113
images:
1214
- identifier: app
13-
prebuildImage: ghcr.io/diploi/component-python:[tag]
15+
prebuildImage: public.ecr.aws/p8t2q7f4/diploi/component-python:[tag]

0 commit comments

Comments
 (0)