-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2c2749
commit 39d3991
Showing
36 changed files
with
1,428 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: "docker-debug" | ||
|
||
on: push | ||
|
||
jobs: | ||
build-images: | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_REPO: "seemscloud" | ||
steps: | ||
- name: "[Repository] Clone" | ||
uses: actions/checkout@v2 | ||
- name: "[Login] Docker Hub" | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: "[Setup] JDK 17" | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
architecture: x64 | ||
- name: "[Build] Maven Clean Package" | ||
run: | | ||
mvn clean package | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "VersionerBot" | ||
mvn clean install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM alpine:latest | ||
|
||
ARG USER_HOME="/tmp/debug" | ||
ARG USER_NAME="debug" | ||
ARG USER_UID="1000" | ||
ARG GROUP_NAME="${USER_NAME}" | ||
ARG GROUP_UID="${USER_UID}" | ||
|
||
ARG KUBECTL_VERSION="1.25.3" | ||
|
||
RUN addgroup -g "${GROUP_UID}" "${GROUP_NAME}" && \ | ||
adduser -G "${GROUP_NAME}" -s /bin/bash -u "${USER_UID}" -h "${USER_HOME}" "${USER_NAME}" -D | ||
|
||
RUN apk update && \ | ||
apk add bash | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN apk add bind-tools iperf3 busybox-extras curl fio | ||
|
||
RUN wget "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" -O /usr/local/bin/kubectl && \ | ||
chmod 0755 /usr/local/bin/kubectl | ||
|
||
COPY docker-entrypoint.sh / | ||
|
||
WORKDIR "${USER_HOME}" | ||
USER "${USER_NAME}" | ||
|
||
ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
while true; do | ||
true | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>pom</packaging> | ||
|
||
<artifactId>cicd.images.debug</artifactId> | ||
<groupId>com.seemscloud.cicd.images.debug</groupId> | ||
|
||
<parent> | ||
<artifactId>cicd.images</artifactId> | ||
<groupId>com.seemscloud.cicd.images</groupId> | ||
<version>1.4.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<configuration> | ||
<verbose>true</verbose> | ||
<images> | ||
<image> | ||
<alias>debug</alias> | ||
<name>${env.DOCKER_REPO}/debug:latest</name> | ||
<build> | ||
<contextDir>${project.basedir}</contextDir> | ||
<filter>@</filter> | ||
</build> | ||
</image> | ||
<image> | ||
<alias>debug</alias> | ||
<name>${env.DOCKER_REPO}/debug:${project.version}</name> | ||
<build> | ||
<contextDir>${project.basedir}</contextDir> | ||
<filter>@</filter> | ||
</build> | ||
</image> | ||
</images> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>build docker</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>push docker</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>push</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM python:3.11-alpine | ||
|
||
ARG USER_HOME="/app" | ||
ARG USER_NAME="app" | ||
ARG USER_UID="1000" | ||
ARG GROUP_NAME="${USER_NAME}" | ||
ARG GROUP_UID="${USER_UID}" | ||
|
||
ENV PATH="${PATH}:${USER_HOME}/.local/bin/" | ||
|
||
RUN addgroup -g "${GROUP_UID}" "${GROUP_NAME}" && \ | ||
adduser -G "${GROUP_NAME}" -s /bin/bash -u "${USER_UID}" -h "${USER_HOME}" "${USER_NAME}" -D | ||
|
||
RUN apk update && \ | ||
apk add bash | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN apk add bind-tools iperf3 busybox-extras curl fio | ||
|
||
COPY docker-entrypoint.sh / | ||
|
||
WORKDIR "${USER_HOME}" | ||
USER "${USER_NAME}" | ||
|
||
COPY ./src/* . | ||
|
||
RUN python3 -m pip install --upgrade pip && \ | ||
python3 -m pip install --upgrade hypercorn uvicorn fastapi | ||
|
||
ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
CONF_COLORS="$CONF_COLORS" | ||
|
||
function logger_format() { | ||
DATE=$(date +"%Y-%m-%d %H:%M:%S,%3N") | ||
|
||
if [[ "${CONF_COLORS}" == "true" ]]; then | ||
echo -e "${DATE} \e[${3}m${1}\e[m\t ${2}" | ||
else | ||
echo -e "${DATE} ${1}\t ${2}" | ||
fi | ||
} | ||
|
||
function logger_msg() { | ||
if [ "${2}" == "error" ]; then | ||
logger_format "ERROR" "${1}" "91" | ||
elif [ "${2}" == "success" ]; then | ||
logger_format "SUCCESS" "${1}" "92" | ||
elif [ "${2}" == "warning" ]; then | ||
logger_format "WARNING" "${1}" "93" | ||
elif [ "${2}" == "info" ]; then | ||
logger_format "INFO" "${1}" "96" | ||
else | ||
logger_format "LOGGER" "Incorrect logger type: '${2}'.." "31" && exit 4 | ||
fi | ||
} | ||
|
||
function logger() { | ||
[ "${#}" -lt 2 ] || [ "${#}" -gt 2 ] && exit 1 | ||
|
||
logger_msg "${2}" "${1}" | ||
} | ||
|
||
# Main | ||
|
||
if [ "${SERVER_TYPE}" == "hypercorn" ]; then | ||
logger info "Starting '${SERVER_TYPE}' server.." | ||
|
||
hypercorn --bind "0.0.0.0:${SERVER_PORT}" app:app | ||
elif [ "${SERVER_TYPE}" == "uvicorn" ]; then | ||
logger info "Starting '${SERVER_TYPE}' server.." | ||
|
||
uvicorn --host "0.0.0.0" --port "${SERVER_PORT}" app:app | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>pom</packaging> | ||
|
||
<artifactId>cicd.images.fastapi</artifactId> | ||
<groupId>com.seemscloud.cicd.images.fastapi</groupId> | ||
|
||
<parent> | ||
<artifactId>cicd.images</artifactId> | ||
<groupId>com.seemscloud.cicd.images</groupId> | ||
<version>1.4.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<configuration> | ||
<verbose>true</verbose> | ||
<images> | ||
<image> | ||
<alias>fastapi</alias> | ||
<name>seemscloud/fastapi:latest</name> | ||
<build> | ||
<contextDir>${project.basedir}</contextDir> | ||
<filter>@</filter> | ||
</build> | ||
</image> | ||
<image> | ||
<alias>fastapi</alias> | ||
<name>seemscloud/fastapi:${project.version}</name> | ||
<build> | ||
<contextDir>${project.basedir}</contextDir> | ||
<filter>@</filter> | ||
</build> | ||
</image> | ||
</images> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>build docker</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>push docker</id> | ||
<phase>deploy</phase> | ||
<goals> | ||
<goal>push</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from fastapi import FastAPI | ||
|
||
app = FastAPI() | ||
|
||
|
||
@app.get("/") | ||
async def root(): | ||
return {"message": "Hello world!"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM python:3.10-alpine | ||
|
||
ARG USER_HOME="/app" | ||
ARG USER_NAME="grpc" | ||
ARG USER_UID="1000" | ||
ARG GROUP_NAME="${USER_NAME}" | ||
ARG GROUP_UID="${USER_UID}" | ||
|
||
ENV GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="${USER_HOME}/ca.crt.pem" | ||
|
||
RUN addgroup -g "${GROUP_UID}" "${GROUP_NAME}" && \ | ||
adduser -G "${GROUP_NAME}" -s /bin/bash -u "${USER_UID}" -h "${USER_HOME}" "${USER_NAME}" -D | ||
|
||
RUN apk update && \ | ||
apk add bash | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
COPY docker-entrypoint.sh / | ||
|
||
WORKDIR "${USER_HOME}" | ||
USER "${USER_NAME}" | ||
|
||
RUN python3 -m pip install --upgrade pip && \ | ||
python3 -m pip install --upgrade grpcio grpcio-tools | ||
|
||
COPY src . | ||
|
||
ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
CONF_COLORS="$CONF_COLORS" | ||
|
||
function logger_format() { | ||
DATE=$(date +"%Y-%m-%d %H:%M:%S,%3N") | ||
|
||
if [[ "${CONF_COLORS}" == "true" ]]; then | ||
echo -e "${DATE} \e[${3}m${1}\e[m\t ${2}" | ||
else | ||
echo -e "${DATE} ${1}\t ${2}" | ||
fi | ||
} | ||
|
||
function logger_msg() { | ||
if [ "${2}" == "error" ]; then | ||
logger_format "ERROR" "${1}" "91" | ||
elif [ "${2}" == "success" ]; then | ||
logger_format "SUCCESS" "${1}" "92" | ||
elif [ "${2}" == "warning" ]; then | ||
logger_format "WARNING" "${1}" "93" | ||
elif [ "${2}" == "info" ]; then | ||
logger_format "INFO" "${1}" "96" | ||
else | ||
logger_format "LOGGER" "Incorrect logger type: '${2}'.." "31" && exit 4 | ||
fi | ||
} | ||
|
||
function logger() { | ||
[ "${#}" -lt 2 ] || [ "${#}" -gt 2 ] && exit 1 | ||
|
||
logger_msg "${2}" "${1}" | ||
} | ||
|
||
# Defaults | ||
|
||
if [ -z "${ENDPOINT}" ]; then | ||
logger info "'ENDPOINT' is not set, using default endpoint 'localhost:9000'" | ||
|
||
ENDPOINT="localhost:9000" | ||
fi | ||
|
||
# Main | ||
|
||
logger info "Connection to '${ENDPOINT}', TLS: '${USE_TLS}'.." | ||
python3 -u client.py |
Oops, something went wrong.