Skip to content

Commit 84ba2c6

Browse files
authored
Merge pull request #13 from joagonzalez/rc-v0.1.0
Rc v0.1.0
2 parents ea4b500 + e525a94 commit 84ba2c6

File tree

6 files changed

+157
-4
lines changed

6 files changed

+157
-4
lines changed

.github/workflows/pipeline.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ jobs:
7272
run: |
7373
make test
7474
75+
- name: Log in to Docker Hub (rc-* only)
76+
if: startsWith(github.ref_name, 'rc-')
77+
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login -u "${{ secrets.REGISTRY_USER }}" --password-stdin
78+
env:
79+
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
80+
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
81+
7582
- name: Build and push Docker image (rc-* only)
7683
if: startsWith(github.ref_name, 'rc-')
7784
run: |
@@ -87,10 +94,11 @@ jobs:
8794
echo "$KUBECONFIG_B64" | base64 -d > kubeconfig.yaml
8895
export KUBECONFIG=$PWD/kubeconfig.yaml
8996
97+
export IMAGE_TAG=${{ steps.gitinfo.outputs.version }}
9098
kubectl version --client
9199
kubectl config get-contexts
92-
echo "Deploying version ${{ steps.gitinfo.outputs.version }}"
93-
kubectl apply -f build/calculator/k8s/
100+
echo "Deploying version $IMAGE_TAG"
101+
envsubst < build/k8s/calculator.yaml | kubectl apply -f -
94102
95103
- name: Publish coverage to Coveralls (master only)
96104
if: github.ref_name == 'master'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ __pycache__/
88

99
# Distribution / packaging
1010
.Python
11-
build/
11+
# build/
1212
develop-eggs/
1313
dist/
1414
downloads/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ checklist: typehint lint test clean
3939
code-quality: typehint lint clean
4040

4141
coverage-publish:
42-
COVERALLS_REPO_TOKEN=$(COVERALLS_REPO_TOKEN) coveralls
42+
uv run COVERALLS_REPO_TOKEN=$(COVERALLS_REPO_TOKEN) coveralls
4343

4444
.PHONY: checklist

build/calculator/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM python:3.11-alpine
2+
3+
# Set build directory
4+
WORKDIR /tmp
5+
6+
# Perform build and cleanup artifacts
7+
RUN apk add --no-cache \
8+
git curl \
9+
&& apk add --no-cache --virtual .build gcc musl-dev make\
10+
&& apk del .build gcc musl-dev \
11+
&& rm -rf /tmp/*
12+
13+
# Install uv
14+
RUN pip install --user uv
15+
16+
ENV PATH=$PATH:/root/.local/bin
17+
18+
# Set working directory
19+
RUN mkdir /app
20+
WORKDIR /app
21+
COPY ./ ./
22+
23+
# Install dependencies using uv
24+
RUN uv sync
25+
26+
# Expose FastAPI development server port
27+
EXPOSE 5000
28+
29+
# Start development server by default
30+
ENTRYPOINT ["uv", "run", "python", "run.py"]
31+
CMD ["uv", "run", "python", "run.py"]

build/documentation/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM python:3.11-alpine
2+
3+
# Set build directory
4+
WORKDIR /tmp
5+
6+
# Copy files necessary for build
7+
COPY requirements.txt requirements.txt
8+
9+
# COPY setup.py setup.py
10+
11+
# Perform build and cleanup artifacts
12+
RUN apk add --no-cache \
13+
git curl \
14+
&& apk add --no-cache --virtual .build gcc musl-dev \
15+
&& pip install --user -r requirements.txt \
16+
&& apk del .build gcc musl-dev \
17+
&& rm -rf /tmp/*
18+
19+
ENV PATH=$PATH:/root/.local/bin
20+
# Set working directory
21+
22+
RUN mkdir /app
23+
WORKDIR /app
24+
COPY ./ ./
25+
26+
# Expose MkDocs development server port
27+
EXPOSE 8000
28+
29+
# Start development server by default
30+
ENTRYPOINT ["mkdocs"]
31+
CMD ["serve", "--dev-addr=0.0.0.0:8000"]

build/k8s/calculator.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: calculator-deployment
5+
labels:
6+
app: calculator
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: calculator
12+
template:
13+
metadata:
14+
labels:
15+
app: calculator
16+
spec:
17+
containers:
18+
- name: calculator
19+
image: joagonzalez/python-seed-api:${IMAGE_TAG}
20+
ports:
21+
- containerPort: 5000
22+
env:
23+
- name: ENVIRONMENT
24+
value: "production"
25+
---
26+
apiVersion: v1
27+
kind: Service
28+
metadata:
29+
name: calculator-service
30+
spec:
31+
selector:
32+
app: calculator
33+
ports:
34+
- protocol: TCP
35+
port: 80
36+
targetPort: 5000
37+
type: ClusterIP
38+
---
39+
# Traefik Middleware for HTTPS redirect
40+
apiVersion: traefik.io/v1alpha1
41+
kind: Middleware
42+
metadata:
43+
name: https-redirect
44+
spec:
45+
redirectScheme:
46+
scheme: https
47+
permanent: true
48+
---
49+
# HTTP IngressRoute for redirect
50+
apiVersion: traefik.io/v1alpha1
51+
kind: IngressRoute
52+
metadata:
53+
name: calculator-http
54+
spec:
55+
entryPoints:
56+
- web
57+
routes:
58+
- match: Host(`calculator.qwerty.com.ar`)
59+
kind: Rule
60+
middlewares:
61+
- name: https-redirect
62+
services:
63+
- name: calculator-service
64+
port: 80
65+
---
66+
# HTTPS IngressRoute
67+
apiVersion: traefik.io/v1alpha1
68+
kind: IngressRoute
69+
metadata:
70+
name: calculator-https
71+
spec:
72+
entryPoints:
73+
- websecure
74+
routes:
75+
- match: Host(`calculator.qwerty.com.ar`)
76+
kind: Rule
77+
services:
78+
- name: calculator-service
79+
port: 80
80+
middlewares:
81+
- name: secure-headers
82+
tls:
83+
certResolver: letsencrypt

0 commit comments

Comments
 (0)