Skip to content

Commit a129a8f

Browse files
Merge pull request #13 from PeerPrep/ajay/setup-executor-service
Setup executor service
2 parents 1f26d65 + cd69b6a commit a129a8f

File tree

17 files changed

+193
-0
lines changed

17 files changed

+193
-0
lines changed

.github/workflows/build-docker-images.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,36 @@ on:
77
- master
88

99
env:
10+
EXECUTOR_IMAGE_NAME: peerprep-executor-service
1011
QUESTIONS_IMAGE_NAME: peerprep-questions-service
1112
FRONTEND_IMAGE_NAME: peerprep-frontend
1213
NGINX_IMAGE_NAME: peerprep-nginx
1314

1415
jobs:
16+
build-executor-image:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
steps:
22+
- name: Check out Source
23+
uses: actions/checkout@v2
24+
with:
25+
submodules: recursive
26+
- name: Log in to the Container Registry
27+
uses: docker/login-action@v1
28+
with:
29+
registry: ghcr.io
30+
username: peerprep
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Build and Push Docker Image
33+
uses: docker/build-push-action@v2
34+
with:
35+
context: .
36+
file: deployment/Dockerfile-executor
37+
push: true
38+
tags: ghcr.io/peerprep/${{ env.EXECUTOR_IMAGE_NAME }}:latest
39+
1540
build-questions-image:
1641
runs-on: ubuntu-latest
1742
permissions:

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "executor/libs/cppevent-base"]
2+
path = executor/libs/cppevent-base
3+
url = https://github.com/Manoharan-Ajay-Anand/cppevent-base.git
4+
[submodule "executor/libs/cppevent-net"]
5+
path = executor/libs/cppevent-net
6+
url = https://github.com/Manoharan-Ajay-Anand/cppevent-net.git
7+
[submodule "executor/libs/cppevent-fcgi"]
8+
path = executor/libs/cppevent-fcgi
9+
url = https://github.com/Manoharan-Ajay-Anand/cppevent-fcgi.git

.vscode/c_cpp_properties.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/executor/libs/cppevent-base/src",
7+
"${workspaceFolder}/executor/libs/cppevent-net/src",
8+
"${workspaceFolder}/executor/libs/cppevent-fcgi/src"
9+
],
10+
"defines": [],
11+
"compilerPath": "/usr/bin/gcc",
12+
"cStandard": "c17",
13+
"cppStandard": "c++20",
14+
"intelliSenseMode": "linux-gcc-x64",
15+
"configurationProvider": "ms-vscode.cpptools"
16+
}
17+
],
18+
"version": 4
19+
}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"files.associations": {
3+
"iosfwd": "cpp"
4+
},
5+
"cmake.sourceDirectory": "${workspaceFolder}/executor",
6+
"cmake.buildDirectory": "${workspaceFolder}/executor/build"
7+
}

deployment/Dockerfile-executor

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM nixos/nix
2+
3+
# Environment variables
4+
ENV APP_ROOT /executor
5+
6+
# Copy source code into container
7+
RUN mkdir --parents $APP_ROOT
8+
WORKDIR $APP_ROOT
9+
COPY executor .
10+
11+
RUN nix-channel --update
12+
13+
RUN nix-build
14+
15+
EXPOSE 9000
16+
17+
CMD ["./executor.sh"]

deployment/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ services:
1414
expose:
1515
- "27017"
1616

17+
executor:
18+
image: ghcr.io/peerprep/peerprep-executor-service:latest
19+
container_name: peerprep-executor-service
20+
restart: always
21+
networks:
22+
- peerprep-network
23+
logging:
24+
driver: journald
25+
expose:
26+
- "9000"
27+
1728
questions:
1829
image: ghcr.io/peerprep/peerprep-questions-service:latest
1930
container_name: peerprep-questions-service
@@ -35,6 +46,7 @@ services:
3546
restart: always
3647
depends_on:
3748
- questions
49+
- executor
3850
networks:
3951
- peerprep-network
4052
logging:

deployment/nginx/sites-enabled/peerprep.sivarn.com

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ server {
5959
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
6060
proxy_set_header X-Forwarded-Proto $scheme;
6161
}
62+
63+
location /api/v1/execute/ {
64+
include /etc/nginx/fastcgi_params;
65+
fastcgi_pass peerprep-executor-service:9000;
66+
}
6267
}
6368

6469
server {

executor/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

executor/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
3+
project(executor
4+
VERSION 1.0
5+
DESCRIPTION "executor service"
6+
LANGUAGES CXX)
7+
8+
set(CMAKE_CXX_STANDARD 20)
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
10+
11+
add_subdirectory(libs/cppevent-base)
12+
add_subdirectory(libs/cppevent-net)
13+
add_subdirectory(libs/cppevent-fcgi)
14+
15+
add_executable(executor
16+
src/exec_endpoint.cpp
17+
src/main.cpp
18+
)
19+
20+
target_link_libraries(executor PRIVATE cppevent-fcgi)

executor/default.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
with import <nixpkgs> {};
2+
gcc13Stdenv.mkDerivation {
3+
name = "executor";
4+
nativeBuildInputs = [ cmake ];
5+
buildInputs = [ ];
6+
src = builtins.path { path = ./.; name = "executor"; };
7+
8+
dontUseCmakeConfigure = true;
9+
10+
buildPhase = ''
11+
cmake -DCMAKE_BUILD_TYPE=Release -S . -B ./build
12+
cmake --build ./build --config Release
13+
'';
14+
15+
installPhase = ''
16+
mkdir -p $out/bin
17+
cp ./build/executor $out/bin/executor
18+
'';
19+
}

0 commit comments

Comments
 (0)