Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intergration env support #283

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2b0ad66
feat(): init mediator integration environment setup
Christiantyemele Nov 18, 2024
c0126bf
feat(): polish intergration evironment
Christiantyemele Nov 19, 2024
9e812b1
Merge branch 'main' of https://github.com/adorsys/didcomm-mediator-rs…
Christiantyemele Nov 19, 2024
8f790a3
fix(): fix on reviews
Christiantyemele Nov 20, 2024
85dd48a
update(intergration environment): added more description to doc
Christiantyemele Nov 25, 2024
ed3b710
Merge branch 'main' of https://github.com/adorsys/didcomm-mediator-rs…
Christiantyemele Nov 28, 2024
fccc753
merged main into intergration environment
Christiantyemele Nov 28, 2024
1b70cc0
feat(): init kubernetes setup
Christiantyemele Nov 29, 2024
805f954
feat(): Polish k8s integration environment
Christiantyemele Dec 2, 2024
1ef2f73
fix(): moved k8s folder
Christiantyemele Dec 3, 2024
605bfd5
feat(): publishing docker containers to ghcr with action
Christiantyemele Dec 3, 2024
0a62147
feat(): added workflow file for ghcr
Christiantyemele Dec 3, 2024
6d4dd79
update yml
Christiantyemele Dec 3, 2024
10d9a79
update(release): updated release with compose
Christiantyemele Dec 3, 2024
a0e12ff
update release.yml
Christiantyemele Dec 3, 2024
8fa870c
feat(): updated workflow
Christiantyemele Dec 3, 2024
6b85b63
update changed pcakage version version
Christiantyemele Dec 3, 2024
9642d2e
update workflow verification
Christiantyemele Dec 3, 2024
22a7e5f
feat(package): update config
Christiantyemele Dec 3, 2024
12927bd
updated pacakage
Christiantyemele Dec 3, 2024
420e1c0
fix(package): typos fix
Christiantyemele Dec 4, 2024
7a68793
fix(package): correcting yaml
Christiantyemele Dec 4, 2024
165516d
fix(): typos fix
Christiantyemele Dec 4, 2024
6fc8251
fix(): added path env for compose
Christiantyemele Dec 4, 2024
5f9bf20
fix(): removed env form .gitignore
Christiantyemele Dec 4, 2024
4d5998e
fix(): updated compose
Christiantyemele Dec 4, 2024
93db614
fix(package): fixing mediator package
Christiantyemele Dec 4, 2024
d507fa6
fix(package): added env path
Christiantyemele Dec 4, 2024
426a1a7
fix(package): changed branch for action
Christiantyemele Dec 4, 2024
7a35312
fix(): update .env
Christiantyemele Dec 4, 2024
a2425c8
fix(): debugging yml
Christiantyemele Dec 4, 2024
0085807
fix(): updated yml
Christiantyemele Dec 4, 2024
26997ea
fix(): update yml
Christiantyemele Dec 4, 2024
abbe3b0
fix(): handled error when reading env
Christiantyemele Dec 5, 2024
3870bf0
fix(global): updated configs for packaging
Christiantyemele Dec 5, 2024
1b22c59
fix(): update package.yml
Christiantyemele Dec 5, 2024
355563f
updat(): updated package.yml
Christiantyemele Dec 5, 2024
723c8ae
fix(): removed port specification form compose
Christiantyemele Dec 5, 2024
99ec932
Merge branch '245-integration-environment-for-didcomm-mediator-server…
Christiantyemele Dec 5, 2024
b0060b0
fix(): update mongodb automatcic resolution
Christiantyemele Dec 5, 2024
d93060b
update(): modified MONGO_URI
Christiantyemele Dec 5, 2024
b1b8bfe
update(): updated env
Christiantyemele Dec 5, 2024
228f25b
update yaml
Christiantyemele Dec 5, 2024
b1102d3
feat(): update yaml
Christiantyemele Dec 5, 2024
f90bb1f
fix(): env path adjustment
Christiantyemele Dec 6, 2024
ed412d2
fix(): changed database url
Christiantyemele Dec 6, 2024
0e59816
fix(): update .env
Christiantyemele Dec 6, 2024
d52b96f
modified .env
Christiantyemele Dec 6, 2024
a8a11e0
fix(): Updated yaml
Christiantyemele Dec 6, 2024
f299970
fix(): modified yaml to use compose
Christiantyemele Dec 6, 2024
c74694e
update(): env
Christiantyemele Dec 6, 2024
13f6426
fix(polish): updated compose
Christiantyemele Dec 6, 2024
3b37136
fix(): polish intergration environment
Christiantyemele Dec 6, 2024
6185c24
fix(): update to dockerfile
Christiantyemele Dec 6, 2024
e7649d1
fix(): updated dockerfile
Christiantyemele Dec 6, 2024
1e437d3
fix(): updated yaml
Christiantyemele Dec 6, 2024
74e898e
feat(): helm init
Christiantyemele Dec 10, 2024
8c0f026
feat(): polish helm setup
Christiantyemele Dec 11, 2024
2f2ce80
fix(): runing workflow
Christiantyemele Dec 11, 2024
3699500
fix(): updated values file
Christiantyemele Dec 11, 2024
703dcea
feat(polish): deployment environment
Christiantyemele Dec 11, 2024
624e8da
feat(): polish deployment environment
Christiantyemele Dec 16, 2024
1d64f67
feat(): addressed reviews
Christiantyemele Dec 16, 2024
2cfc7d0
feat(): updated host deployment
Christiantyemele Dec 17, 2024
9360723
fix(): added ssl/tls to deployment
Christiantyemele Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/
**/target/
.idea/
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SERVER_PUBLIC_DOMAIN="http://didcomm-mediator.com"
SERVER_LOCAL_PORT="8080"
STORAGE_DIRPATH="crates/generic-server/target/storage"
MONGO_DBN="mediator-coordination"

20 changes: 0 additions & 20 deletions .github/workflows/CD.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish Image

on:
push:
branches:
- '*'
tags:
- 'v*'

env:
IMAGE_NAME: didcomm-mediator-rs

jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME

# Ensure all uppercase characters are converted to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip the git ref prefix from the version
VERSION=latest
# Remove the "v" prefix from the tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use "latest" tag for the main branch
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Cargo.lock

# Environment variables files
.env.example
.env


# Reference crate
mediator-server
Expand Down
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM rust:latest as builder

WORKDIR /app

COPY . .

# Build the server
RUN cargo build --release

# Use a minimal image for running the server
FROM ubuntu

RUN apt update && apt install -y libpq5 && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Set the storage directory path
ENV STORAGE_DIRPATH="crates/generic-server/target/storage"

# Copy the built binary
COPY --from=builder /app/target/release/didcomm-mediator /usr/local/bin/didcomm-mediator

COPY .env .env

# Expose the necessary port
EXPOSE 3000

# Set an entrypoint script to handle the environment file
ENTRYPOINT ["didcomm-mediator"]
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3.8"
services:
mediator:
build:
context: .
container_name: didcomm-mediator
ports:
- "8080:8080"
env_file:
- .env
depends_on:
- mongodb
networks:
- mediator-network

mongodb:
image: mongo:latest
container_name: mongodb
env_file:
- .env
volumes:
- mongo-data:/data/db
networks:
- mediator-network
ports:
- "27017:27017"

networks:
mediator-network:
driver: bridge

volumes:
mongo-data:
81 changes: 81 additions & 0 deletions docs/deployment-environment-doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

# **Application Deployment Documentation**

## **1. Prerequisites**
- **Tools and Software Required**:
- Helm version (e.g., `Helm 3.x`)
- Kubernetes version (e.g., `1.25+`)
- Minikube/Cluster setup
- Other dependencies (e.g., Docker, kubectl, etc.)
- **Environment Setup**:
- Access to the Kubernetes cluster
- Required configurations or credentials


## **3. Helm Chart Structure**
- **Chart Overview**:
- Structure of the Helm chart (values.yaml, templates, etc.).
- Purpose of critical templates (e.g., Deployment, Service, ConfigMap).
- Default vs. custom configurations.
- **Customization**:
- How to override values.yaml using custom configurations.
Example:
```bash
helm install mediator ./mediator-charts --values custom-values.yaml
```
- mandatory values are;

**MONGO_DBN**,
**MONGO_URI**,
**SERVER_LOCAL_PORT** and
**SERVER_PUBLIC_DOMAIN**


## **4. Deployment Guide**
- **Steps to Deploy**:
1. Clone the repository:
```bash
git clone https://github.com/adorsys/didcomm-mediator-rs.git
```
2. Install dependencies:
```bash
helm dependency update mediator-charts
```
3. Deploy using Helm:
```bash
helm install mediator mediator-charts --namespace didcomm-mediator
```
4. Verify deployment status:
```bash
kubectl get pods -n didcomm-mediator
kubectl get services -n didcomm-mediator
```
- **Notes on Namespaces**:
- Importance of creating and using the correct namespace.
- **Rollback Instructions**:
- How to roll back to a previous release:
```bash
helm rollback my-app <revision>
```

---

## **5. Accessing the Application**
- **Port Forwarding**:
- Steps to forward the service ports locally for testing:
```bash
kubectl port-forward service/<service-name> 8080:<target-port>
```
- **Ingress/LoadBalancer Details**:
- Steps to access the application if exposed via Ingress or LoadBalancer.

## **7. Monitoring and Debugging**
- **Logs**:
- How to fetch logs for debugging:
```bash
kubectl logs <pod-name> -n didcomm-mediator
```
- **Monitoring Tools**:
- Mention tools used (e.g., Prometheus, Grafana, ELK Stack).
- Steps to configure and access monitoring dashboards.

23 changes: 23 additions & 0 deletions mediator-charts/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions mediator-charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: mediator-charts
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.9"
16 changes: 16 additions & 0 deletions mediator-charts/templates/env-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
data:
MONGO_DBN: mediatorDB
MONGO_URI: mongodb://mongodb:27017
SERVER_LOCAL_PORT: "3000"
SERVER_PUBLIC_DOMAIN: http://alice-mediator.com

kind: ConfigMap
metadata:
namespace: {{ .Values.namespace }}
creationTimestamp: null
labels:
io.kompose.service: mediator-env
name: env


47 changes: 47 additions & 0 deletions mediator-charts/templates/mediator-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-mediator-deployment
namespace: {{ .Values.namespace }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-mediator
template:
metadata:
labels:
app: {{ .Release.Name }}-mediator
spec:
containers:
- name: {{ .Release.Name }}-mediator-container
image: {{ .Values.mediator.image.repository }}:{{ .Values.mediator.image.tag }}
imagePullPolicy: {{ .Values.mediator.image.pullPolicy }}
ports:
- containerPort: 3000
env:
- name: MONGO_DBN
valueFrom:
configMapKeyRef:
key: MONGO_DBN
name: env
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secret
key: password
- name: MONGO_HOST
value: {{ .Release.Name }}-mongodb-service
- name: MONGO_URI
value: "mongodb://{{ .Release.Name }}-mongodb-service:27017"
- name: SERVER_LOCAL_PORT
valueFrom:
configMapKeyRef:
key: SERVER_LOCAL_PORT
name: env
- name: SERVER_PUBLIC_DOMAIN
valueFrom:
configMapKeyRef:
key: SERVER_PUBLIC_DOMAIN
name: env

17 changes: 17 additions & 0 deletions mediator-charts/templates/mediator-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-mediator-service
annotations:
external-dns.alpha.kubernetes.io/hostname: {{ .Values.externalDnsHostname }}
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: {{ .Values.certificateArn }}
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
namespace: {{ .Values.namespace }}
spec:
selector:
app: {{ .Release.Name }}-mediator
ports:
- name: https
port: 443
targetPort: 3000
type: LoadBalancer
Loading
Loading