Skip to content

Commit

Permalink
add workflows and deployment files
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGANGLOFF committed Apr 8, 2024
1 parent ee4ee35 commit 6bf1360
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 18 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Rust-test

on:
push:
branches:
- main
- service-eat
- service-auth
- service-drink
- service-sleep
- service-enjoy
- service-travel
workflow_dispatch:
env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
34 changes: 34 additions & 0 deletions .github/workflows/service-travel-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy Service travel

on:
workflow_run:
workflows: ["Rust-test"]
types:
- completed

jobs:
build-push-and-deploy:
runs-on: debian:bookworm@sha256:c2cedd7f80a4dd0f9f80d3699bd433ccf3de33ab63bfa2d4c4ba870c998222d6
steps:
- uses: actions/checkout@v2

- name: Build the Docker image
run: docker build . --file Dockerfile --tag d3spina/t-web-800:travel-latest

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push the Docker image
run: docker push d3spina/t-web-800:travel-latest

- name: Set up Kubeconfig
run: echo "${{ secrets.KUBE_CONFIG }}" | base64 --decode > $HOME/.kube/config

- name: Deploy to Kubernetes
run: |
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl rollout status deployment/travel -n travel
18 changes: 4 additions & 14 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage de construction
FROM rust:latest as builder
FROM rust:latest@sha256:84d4e88a86481073bf876770768632d8c7783fc58f14fbd67b387f75f889db23 as builder

# Copiez tous les membres du workspace ainsi que le fichier de workspace.
# Pre-building de travel pour le caching des dépendances
Expand All @@ -12,8 +12,9 @@ COPY .env .env
# Création du build release
RUN cargo build --release


# Stage d'exécution
FROM ubuntu:latest
FROM debian:bookworm@sha256:c2cedd7f80a4dd0f9f80d3699bd433ccf3de33ab63bfa2d4c4ba870c998222d6
RUN apt-get update && apt-get install -y openssl && apt-get install -y ca-certificates && \
update-ca-certificates && \
rm -rf /var/lib/apt/lists/*
Expand Down
37 changes: 37 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: travel
namespace: travel
labels:
name: travel
spec:
replicas: 2
selector:
matchLabels:
app: travel
template:
metadata:
labels:
app: travel
spec:
containers:
- name: travel
image: d3spina/t-web-800:travel-latest
imagePullPolicy: Always
env:
- name: ROCKET_ADDRESS
value: "0.0.0.0"
- name: ROCKET_PORT
value: "8005"
ports:
- containerPort: 8005
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
imagePullSecrets:
- name: my-docker-credentials
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
dockerfile: Dockerfile
image: travel
ports:
- "8005:8000"
- "8005:8005"
environment:
ROCKET_ADDRESS: "0.0.0.0"
ROCKET_ADDRESS: "0.0.0.0"
ROCKET_PORT: "8005"
13 changes: 13 additions & 0 deletions service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: travel-service
namespace: travel
spec:
selector:
app: travel
ports:
- protocol: TCP
port: 80
targetPort: 8005
type: LoadBalancer

0 comments on commit 6bf1360

Please sign in to comment.