Skip to content

Commit

Permalink
ZIL-5408: Dockerise PDT (#218)
Browse files Browse the repository at this point in the history
* Dockerise PDT

* Update workflow and makefile

* Update Apt and workdir

* Remove libssl-dev on image

* Update dockerfile and add deployment config

* Update dockerfile to accommodate all warnings

* update cicd

* Migrate to Kustomize

* Remove ingress and svc

* Remove PV, certificates and ingress

* Remove pv references
  • Loading branch information
WuBruno authored Oct 12, 2023
1 parent e408d49 commit bb37728
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cicd-stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
- application: neo-savant
image_name: neo-savant
path: products/neo-savant
- application: pdt
image_name: pdt
path: products/pdt
env:
DOCKER_DOMAIN: asia-docker.pkg.dev
REGISTRY: asia-docker.pkg.dev/prj-d-devops-services-4dgwlsse/zilliqa-public
Expand Down
6 changes: 6 additions & 0 deletions products/pdt/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target/
.vscode/
# Target for downloaded files
downloads/
# Stores download metadata
meta.json
21 changes: 16 additions & 5 deletions products/pdt/Cargo.lock

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

27 changes: 27 additions & 0 deletions products/pdt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Requires alpine to get openssl and build
FROM rust:1.71.0-bullseye as builder

WORKDIR /pdt

RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends protobuf-compiler=3.12.4-1+deb11u1 build-essential=12.9 cmake=3.18.4-2+deb11u1

RUN mkdir build

COPY . .

RUN --mount=type=cache,target=/usr/local/cargo/registry cargo build && \
mv /pdt/target/debug/pdt /pdt/build/

FROM debian:bullseye-slim

RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends ca-certificates=20210119 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder /pdt/build/pdt /pdt

CMD ["/pdt", "test"]
13 changes: 13 additions & 0 deletions products/pdt/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: all
all: image/build-and-push

.ONESHELL:
SHELL := /bin/bash
.SHELLFLAGS = -ec

IMAGE_TAG ?= localhost:5001/pdt:latest

## Build and push the Docker image
image/build-and-push:
docker build -t "${IMAGE_TAG}" .
docker push "${IMAGE_TAG}"
24 changes: 24 additions & 0 deletions products/pdt/cd/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pdt
namespace: pdt
labels:
"app.kubernetes.io/name": "pdt"
spec:
replicas: 1
selector:
matchLabels:
"app.kubernetes.io/name": "pdt"
strategy:
type: RollingUpdate
template:
metadata:
labels:
"app.kubernetes.io/name": "pdt"
spec:
containers:
- image: pdt
name: pdt
ports:
- containerPort: 80
6 changes: 6 additions & 0 deletions products/pdt/cd/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- pvc.yaml
- deployment.yaml
4 changes: 4 additions & 0 deletions products/pdt/cd/base/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: pdt
11 changes: 11 additions & 0 deletions products/pdt/cd/base/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pdt-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 128Gi
storageClassName: standard
7 changes: 7 additions & 0 deletions products/pdt/cd/overlays/staging/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base

namespace: pdt-staging
16 changes: 16 additions & 0 deletions products/pdt/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"
services:
pdt:
environment:
RUST_BACKTRACE: 1
build:
context: .
dockerfile: Dockerfile
container_name: pdt
volumes:
- "download_data:/var/download_data"
command:
- /pdt
- test
volumes:
download_data:
1 change: 1 addition & 0 deletions products/pdt/pdt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pdtdb = { path = "../pdtdb" }
pdtpsql = { path = "../pdtpsql" }
pdtparse = { path = "../pdtparse" }
pdtlisten = { path = "../pdtlisten" }
openssl = { version = "0.10.57", features = ["vendored"] }
tokio = { version = "1.28.1", features = [
"macros",
"rt-multi-thread",
Expand Down
6 changes: 6 additions & 0 deletions products/pdt/pdt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ enum Commands {
ParseEvents,
#[command(name = "listen")]
Listen(ListenOptions),
#[command(name = "test")]
Test,
}

// #[derive(Debug, Args)]
Expand Down Expand Up @@ -364,5 +366,9 @@ async fn main() -> Result<()> {
)
.await
}
Commands::Test => {
println!("Hello World");
loop {}
}
}
}

0 comments on commit bb37728

Please sign in to comment.