Skip to content

Commit

Permalink
speedrun to clone MAL lists [8/n]
Browse files Browse the repository at this point in the history
🧱 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.
  • Loading branch information
deomorxsy committed Apr 8, 2024
1 parent b3c9295 commit 31a675f
Show file tree
Hide file tree
Showing 17 changed files with 1,485 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER && \
chown -R $APPLICATION_USER /app
USER 1000

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

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



19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL=/bin/bash

skeleton=$(shell source ./scripts/setup.sh; mvn_skeleton)
spring=$(shell source ./scripts/setup.sh; spring_setup)
compose=$(shell source ./scripts/ccr.sh; call checker)
compose=$(shell source ./scripts/ccr.sh; checker)

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

image:
podman build -t localhost:5000/mcl_slimjre:v03 -f ./Dockerfile

# cronjob for the ci hook method to fetch the API on the mainClass
fetchapi:
0 0 * * 1 /bin/mvn compile exec:java -Dexec.mainClass="com.meucafelist.app.App" -f ./server/pom.xml -e

# cronjob for the ci hook method to convert the XML file (workflow artifact) to json format
xmltojson:
0 0 * * 4 /bin/mvn compile exec:java -Dexec.mainClass="com.meucafelist.app.App" -f ./server/pom.xml -e

# up containers
up:
@$(call compose)
docker compose -f ./compose.yml up
up_server:
@$(call compose)
docker compose -f ./compose.yml up server
up_client:
@$(call compose)
docker compose -f ./compose.yml up client

down:
@$(call compose)
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The second attempt is to make the app ~**blazingly**~ fast by having a slim cont
- [amazon-corretto-22]() as JRE;
- symbol stripping with [jlink]();
- 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
- 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.

## Usage

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

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

## Deployment

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:
- server: the SpringBoot application on a slim JRE with amazon-corretto and the Alpine distro.
- 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/).
- nginx as web server, reverse proxy, etc.

### compose

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.

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.

Source the script and run it to run compose with podman, or just put a ```make up```. XD

```sh
; source ./scripts/ccr.sh; checker
```

### k8s
> soon...
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.
4 changes: 4 additions & 0 deletions client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode
target
._target
notes.md
8 changes: 8 additions & 0 deletions client/.env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# APP
APP_NAME=mclFront
RUN_ENV=dev
HOST=0.0.0.0
PORT=8080

# CORS
CORS_ALLOWED=*
82 changes: 82 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This file should only ignore things that are generated during a `x.py` build,
# generated by common IDEs, and optional files controlled by the user that
# affect the build (such as config.toml).
# In particular, things like `mir_dump` should not be listed here; they are only
# created during manual debugging and many people like to clean up instead of
# having git ignore such leftovers. You can use `.git/info/exclude` to
# configure your local ignore list.

## File system
.DS_Store
desktop.ini

## Editor
*.swp
*.swo
Session.vim
.cproject
.idea
*.iml
.vscode
.project
.favorites.json
.settings/
.vs/

## Tool
.valgrindrc
.cargo
# Included because it is part of the test case
!/tests/run-make/thumb-none-qemu/example/.cargo

## Configuration
/config.toml
/Makefile
config.mk
config.stamp
no_llvm_build

## Build
/dl/
/doc/
/inst/
/llvm/
/mingw-build/
build/
!/compiler/rustc_mir_build/src/build/
/build-rust-analyzer/
/dist/
/unicode-downloads
/target
/src/bootstrap/target
/src/tools/x/target
# Created by default with `src/ci/docker/run.sh`
/obj/

## Temporary files
*~
\#*
\#*\#
.#*

## Tags
tags
tags.*
TAGS
TAGS.*

## Python
__pycache__/
*.py[cod]
*$py.class

## Node
node_modules
package-lock.json
package.json

## Rustdoc GUI tests
tests/rustdoc-gui/src/**.lock

# Before adding new lines, see the comment at the top.

Loading

0 comments on commit 31a675f

Please sign in to comment.