Skip to content

Commit

Permalink
Merge branch 'main' into remove-docker-compose-folder
Browse files Browse the repository at this point in the history
  • Loading branch information
svrnm committed Dec 17, 2024
2 parents 74a0f2d + e0d162c commit ae9f89e
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-images-on-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- "src/loaders/**"
- "src/services/**"
- "src/databases/**"
- ".version"
- ".github/workflows/reusable-build-container-images.yml"
- ".github/workflows/build-images-on-commit.yml"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-images-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- "src/loaders/**"
- "src/services/**"
- "src/databases/**"
- ".version"
- ".github/workflows/reusable-build-container-images.yml"
- ".github/workflows/check.yml"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/reusable-build-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
name: loaders-curl
- context: ./src/services/java
name: services-java
- context: ./src/services/nodejs
name: services-nodejs
- context: ./src/databases/mysql
name: databases-mysql
steps:
- name: Checkout
uses: actions/[email protected]
Expand Down
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
.vscode/

# Local History for Visual Studio Code
.history/
Expand Down
10 changes: 10 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ for DIR in "${REPO_DIR}/src/services"/*; do
fi
done

for DIR in "${REPO_DIR}/src/databases"/*; do
if [ -d "$DIR" ]; then
IMAGE_TAG="${REPO_PREFIX}/${IMAGE_PREFIX}-databases-$(basename "$DIR"):$VERSION"
echo "Building $IMAGE_TAG..."
echo "Running 'docker buildx build --platform $PLATFORM -t $IMAGE_TAG $DIR $PUSH'"
docker buildx build --platform "$PLATFORM" -t "$IMAGE_TAG" $PUSH "$DIR" $PUSH
fi
done

for DIR in "${REPO_DIR}/src/loaders"/*; do
if [ -d "$DIR" ]; then
IMAGE_TAG="${REPO_PREFIX}/${IMAGE_PREFIX}-loaders-$(basename "$DIR"):$VERSION"
Expand All @@ -64,3 +73,4 @@ for DIR in "${REPO_DIR}/src/loaders"/*; do
docker buildx build --platform "$PLATFORM" -t "$IMAGE_TAG" $PUSH "$DIR" $PUSH
fi
done

9 changes: 9 additions & 0 deletions src/databases/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mysql:5.7

LABEL org.opencontainers.image.source=https://github.com/cisco-open/app-simulator
LABEL org.opencontainers.image.description="mysql database for app-simulator"
LABEL org.opencontainers.image.licenses=BSD-3-Clause

RUN yum install -y php-cli && yum clean all
COPY setup.php /tmp/
COPY setup.sh /docker-entrypoint-initdb.d/
33 changes: 33 additions & 0 deletions src/databases/mysql/setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
echo "Setup ...".PHP_EOL;

$config = json_decode($_SERVER['APP_CONFIG']);

$result = "";

foreach($config->databases as $database => $tables) {
$result .= "CREATE DATABASE ".$database.";".PHP_EOL;
$result .= "USE ".$database.";".PHP_EOL;
foreach($tables as $table => $columns) {
$result .="CREATE TABLE ".$table." (".PHP_EOL;
foreach($columns as $column) {
if($column === 'id') {
$result .= " ".$column." INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,".PHP_EOL;
} else {
$result .= " ".$column. " VARCHAR(255),".PHP_EOL;
}
}

$result = substr($result,0,-2).PHP_EOL;

$result .=') ENGINE=InnoDB;'.PHP_EOL;
}
}

echo '=====.PHP_EOL';

echo $result;

echo '=====.PHP_EOL';

file_put_contents("/tmp/create.sql",$result);
3 changes: 3 additions & 0 deletions src/databases/mysql/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
APP_CONFIG="$(</config.json)" php /tmp/setup.php
mysql -uroot -p${MYSQL_ROOT_PASSWORD} < /tmp/create.sql
2 changes: 1 addition & 1 deletion src/loaders/curl/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.20.3

LABEL org.opencontainers.image.source https://github.com/cisco-open/app-simulator
LABEL org.opencontainers.image.source=https://github.com/cisco-open/app-simulator
LABEL org.opencontainers.image.description="curl loader for app-simulator"
LABEL org.opencontainers.image.licenses=BSD-3-Clause

Expand Down
2 changes: 1 addition & 1 deletion src/services/java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN mvn -f /home/app/pom.xml clean package

FROM openjdk:11-jre

LABEL org.opencontainers.image.source https://github.com/cisco-open/app-simulator
LABEL org.opencontainers.image.source=https://github.com/cisco-open/app-simulator
LABEL org.opencontainers.image.description="java service for app-simulator"
LABEL org.opencontainers.image.licenses=BSD-3-Clause

Expand Down
4 changes: 4 additions & 0 deletions src/services/nodejs/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
package-lock.json
run.sh
4 changes: 4 additions & 0 deletions src/services/nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
package-lock.json
node.log
13 changes: 13 additions & 0 deletions src/services/nodejs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:18

LABEL org.opencontainers.image.source=https://github.com/cisco-open/app-simulator
LABEL org.opencontainers.image.description="nodejs service for app-simulator"
LABEL org.opencontainers.image.licenses=BSD-3-Clause

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN chmod +x /app/entrypoint.sh
EXPOSE 80
CMD ["/app/entrypoint.sh"]
4 changes: 4 additions & 0 deletions src/services/nodejs/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
echo "Running server on :8080"
APP_CONFIG="$(</config.json)" node index.js 8080
#fi
Loading

0 comments on commit ae9f89e

Please sign in to comment.