Skip to content

Commit 31a675f

Browse files
committed
speedrun to clone MAL lists [8/n]
🧱 finishing the infra stage [1/n] ✨feat: add skeleton for the ci hook methods; [1/n] - fetch the API on the mainClass - convert the XML file (workflow artifact) to json format - todo: sanitize then synchronize with backend REST API 🍻 ✨feat: add Rust project scaffolding for the front-end using actix-rs 📝add: Dockerfile for the actix-rs calling from Alpine and Debian 📝 style: add deploy stuff on the README.md documentation 🚀 add: cronjob targets on the Makefile for automated build by the Actions CI runner [1/n] ♻️ refactor: feat - fix syntax typos for the shellscript at scripts/ccr.sh - this makes the compose a little distribution independent since it prioritizes the Podman Service systemd's socket unit file as DOCKER_HOST, so you don't have to run the docker daemon on background, although still depends on systemd.
1 parent b3c9295 commit 31a675f

File tree

17 files changed

+1485
-10
lines changed

17 files changed

+1485
-10
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER && \
4545
chown -R $APPLICATION_USER /app
4646
USER 1000
4747

48-
COPY --chown=1000:1000 ./server/src/main/java/com/meucafelist/app/App.java /app/mcl.java
48+
COPY --chown=1000:1000 ./server/src/main/java/com/meucafelist/app/App.java /app/App.java
4949
WORKDIR /app
5050

5151
EXPOSE 8080
5252
#ENTRYPOINT/CMD [ "/jre/bin/java", "-jar", "/app/app.jar" ]
5353
ENTRYPOINT [ "/usr/lib/jvm/default-jvm/bin/java", "/app/mcl.java" ]
54-
#ENTRYPOINT [ "mvn", "compile" "exec:java", "-Dexec.mainClass=", "com.meucafelist.app", "-f", "./server/pom.xml", "-e"]
54+
##ENTRYPOINT [ "mvn", "compile" "exec:java", "-Dexec.mainClass=", "com.meucafelist.app", "-f", "./server/pom.xml", "-e"]
5555

5656

5757

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL=/bin/bash
22

33
skeleton=$(shell source ./scripts/setup.sh; mvn_skeleton)
44
spring=$(shell source ./scripts/setup.sh; spring_setup)
5-
compose=$(shell source ./scripts/ccr.sh; call checker)
5+
compose=$(shell source ./scripts/ccr.sh; checker)
66

77
test:
88
docker compose -f ./compose.yml run
@@ -11,10 +11,27 @@ local:
1111
mvn install -f ./server/pom.xml
1212
mvn compile exec:java -Dexec.mainClass="com.meucafelist.app.App" -f ./server/pom.xml -e
1313

14+
image:
15+
podman build -t localhost:5000/mcl_slimjre:v03 -f ./Dockerfile
1416

17+
# cronjob for the ci hook method to fetch the API on the mainClass
18+
fetchapi:
19+
0 0 * * 1 /bin/mvn compile exec:java -Dexec.mainClass="com.meucafelist.app.App" -f ./server/pom.xml -e
20+
21+
# cronjob for the ci hook method to convert the XML file (workflow artifact) to json format
22+
xmltojson:
23+
0 0 * * 4 /bin/mvn compile exec:java -Dexec.mainClass="com.meucafelist.app.App" -f ./server/pom.xml -e
24+
25+
# up containers
1526
up:
1627
@$(call compose)
1728
docker compose -f ./compose.yml up
29+
up_server:
30+
@$(call compose)
31+
docker compose -f ./compose.yml up server
32+
up_client:
33+
@$(call compose)
34+
docker compose -f ./compose.yml up client
1835

1936
down:
2037
@$(call compose)

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The second attempt is to make the app ~**blazingly**~ fast by having a slim cont
77
- [amazon-corretto-22]() as JRE;
88
- symbol stripping with [jlink]();
99
- to avoid layer bloat, ~only one~ two are being used to download and remove build dependencies. Dockerfile inspired by the official [corretto](https://github.com/corretto/corretto-docker/) repo
10+
- other bloat source is including the test framework inside the container. To avoid this, maven is used in the build process and elimined in the final result.
1011

1112
## Usage
1213

@@ -29,3 +30,26 @@ mvn compile exec:java -Dexec.mainClass="com.meucafelist.app"
2930

3031
1. **make scaff** to run [setup.sh](./scripts/skel.sh) and generate the project skeleton directory structure:
3132

33+
## Deployment
34+
35+
This repository uses Github Actions for Continuous Integration. Similar to how to run manually, the [yaml script](./.github/workflows/ci.yml) calls Makefile, which calls compose.yml, which runs the containers based on the specific Dockerfile context. It consists in three containers:
36+
- server: the SpringBoot application on a slim JRE with amazon-corretto and the Alpine distro.
37+
- frontend: the Actix application frontend on a slim Rust environment. [This](./client/Dockerfile) multi-stage build was inspired by codefeetime's [article](https://www.codefeetime.com/post/docker-config-for-actix-web-diesel-and-postgres/).
38+
- nginx as web server, reverse proxy, etc.
39+
40+
### compose
41+
42+
Compose concentrates in orchestrating multiple containers in a single host. To do this with k8s, you would need kind, k3s (does not use virtualization) or similar. It was made to be compatible with other OCI runtimes, such as Podman, which was one of the first to enable rootless containers, and can be setup with compose using the Podman Service's systemd unit file for unix sockets.
43+
44+
The orchestration tool docker-compose supports Podman Service through the DOCKER_HOST environment variable. This makes it possible to run containers with podman but with the benefit of rootless.
45+
46+
Source the script and run it to run compose with podman, or just put a ```make up```. XD
47+
48+
```sh
49+
; source ./scripts/ccr.sh; checker
50+
```
51+
52+
### k8s
53+
> soon...
54+
55+
Kubernetes is a container orchestrator that have a YAML syntax similar to the CI deployment from this repo. To run this project on single host just like the Compose tool, you can use tools like kind in a full-virtualized environment or k3s which don't use full-virtualization.

client/.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.vscode
2+
target
3+
._target
4+
notes.md

client/.env.docker

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# APP
2+
APP_NAME=mclFront
3+
RUN_ENV=dev
4+
HOST=0.0.0.0
5+
PORT=8080
6+
7+
# CORS
8+
CORS_ALLOWED=*

client/.gitignore

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# This file should only ignore things that are generated during a `x.py` build,
2+
# generated by common IDEs, and optional files controlled by the user that
3+
# affect the build (such as config.toml).
4+
# In particular, things like `mir_dump` should not be listed here; they are only
5+
# created during manual debugging and many people like to clean up instead of
6+
# having git ignore such leftovers. You can use `.git/info/exclude` to
7+
# configure your local ignore list.
8+
9+
## File system
10+
.DS_Store
11+
desktop.ini
12+
13+
## Editor
14+
*.swp
15+
*.swo
16+
Session.vim
17+
.cproject
18+
.idea
19+
*.iml
20+
.vscode
21+
.project
22+
.favorites.json
23+
.settings/
24+
.vs/
25+
26+
## Tool
27+
.valgrindrc
28+
.cargo
29+
# Included because it is part of the test case
30+
!/tests/run-make/thumb-none-qemu/example/.cargo
31+
32+
## Configuration
33+
/config.toml
34+
/Makefile
35+
config.mk
36+
config.stamp
37+
no_llvm_build
38+
39+
## Build
40+
/dl/
41+
/doc/
42+
/inst/
43+
/llvm/
44+
/mingw-build/
45+
build/
46+
!/compiler/rustc_mir_build/src/build/
47+
/build-rust-analyzer/
48+
/dist/
49+
/unicode-downloads
50+
/target
51+
/src/bootstrap/target
52+
/src/tools/x/target
53+
# Created by default with `src/ci/docker/run.sh`
54+
/obj/
55+
56+
## Temporary files
57+
*~
58+
\#*
59+
\#*\#
60+
.#*
61+
62+
## Tags
63+
tags
64+
tags.*
65+
TAGS
66+
TAGS.*
67+
68+
## Python
69+
__pycache__/
70+
*.py[cod]
71+
*$py.class
72+
73+
## Node
74+
node_modules
75+
package-lock.json
76+
package.json
77+
78+
## Rustdoc GUI tests
79+
tests/rustdoc-gui/src/**.lock
80+
81+
# Before adding new lines, see the comment at the top.
82+

0 commit comments

Comments
 (0)