Skip to content

Commit bedcd3c

Browse files
committed
speedrun to clone MAL lists [2/n]
fix: align logic of calls from Makefile -> (compose.yml -> Dockerfile) | (./scripts/setup.sh) fix: add maven to Dockerfile, adjust app name and entrypoint call todo: fix ./scripts/setup.sh todo: refactor ci
1 parent 6ef3e5c commit bedcd3c

File tree

5 files changed

+61
-23
lines changed

5 files changed

+61
-23
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN wget -O /THIRD-PARTY-LICENSES-20200824.tar.gz https://corretto.aws/downloads
1414
SHA_SUM="6cfdf08be09f32ca298e2d5bd4a359ee2b275765c09b56d514624bf831eafb91" && \
1515
echo "${SHA_SUM} /etc/apk/keys/amazoncorretto.rsa.pub" | sha256sum -c - && \
1616
echo "https://apk.corretto.aws" >> /etc/apk/repositories && \
17-
apk add --no-cache amazon-corretto-20=$version-r0 binutils && \
17+
apk add --no-cache amazon-corretto-20=$version-r0 binutils maven && \
1818
/usr/lib/jvm/default-jvm/bin/jlink --add-modules "$(java --list-modules | sed -e 's/@[0-9].*$/,/' | tr -d \\n)" --no-man-pages --no-header-files --strip-debug --output /opt/corretto-slim && \
1919
apk del binutils amazon-corretto-20 && \
2020
mkdir -p /usr/lib/jvm/ && \
@@ -31,10 +31,10 @@ RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER && \
3131
chown -R $APPLICATION_USER /app
3232
USER 1000
3333

34-
COPY --chown=1000:1000 ./jit/sample/jdk-8281677.java /app/jdk-8281677.java
34+
COPY --chown=1000:1000 ./server/src/main/java/com/meucafelist/app/App.java /app/mcl.java
3535
WORKDIR /app
3636

3737
EXPOSE 8080
38-
ENTRYPOINT [ "/usr/lib/jvm/default-jvm/bin/java", "/app/jdk-8281677.java" ]
38+
ENTRYPOINT [ "/usr/lib/jvm/default-jvm/bin/java", "/app/mcl.java" ]
3939
#ENTRYPOINT/CMD [ "/jre/bin/java", "-jar", "/app/app.jar" ]
4040

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
SHELL=/bin/bash
2+
3+
skeleton=$( shell source ./scripts/setup.sh; mvn_skeleton )
4+
spring=$( shell source ./scripts/setup.sh; spring_setup )
5+
6+
test:
7+
docker compose -f ./compose.yml run
8+
9+
up:
10+
docker compose -f ./compose.yml up
11+
12+
down:
13+
docker compose -f ./compose.yml down
14+
15+
build:
16+
docker compose -f ./compose.yml build
17+
18+
scaff:
19+
@echo "[Scaffolding] creating directory structure..."
20+
@$(call skeleton)
21+
@echo "[Scaffolding] setting up SpringBoot..."
22+
@$(call spring)

README.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
# meuCafeList
22

3+
A speedrun attempt to clone MAL anime and manga lists into a github pages subdomain, using SpringBoot. IaC automation provided by OCI containers, compose, github actions and scaffolding with shellscript.
34

4-
## usage
5+
## Usage
56

67
1. clone repository with SSH and enter directory
78
```sh
8-
git clone [email protected]:deomorxsy/htbirb.git
9-
cd ./htbirb/
9+
git clone [email protected]:deomorxsy/meuCafeList.git
10+
cd ./meuCafeList/
1011
```
1112

12-
2. build and run with maven, a package manager and build tool
13+
2. **make build** to build with:
1314
```sh
1415
mvn compile exec:java -Dexec.mainClass="com.meucafelist.app"
1516
```
17+
3. **make test** to test the app.
1618

17-
## creating a similar structure
18-
the project follows the steps for setup:
19+
4. **make up/down** to respectively run or stop the app.
1920

20-
run [mavenado.sh](./scripts/mavenado.sh) to generate the project skeleton directory structure:
21-
```
22-
sh ./scripts/mavenado.sh
23-
```
21+
5.
2422

25-
to generate a springboot directory structure, add the maven plugin to the pom.xml generated by the previous step.
26-
```
27-
```
28-
29-
generating an OCI container image:
30-
```
31-
```
23+
## Scaffolding
3224

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

compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: "3.8"
2+
services:
3+
server:
4+
restart: always
5+
build:
6+
context: ./
7+
target: builder
8+
command:
9+
stop_signal: SIGINT
10+
nginx:
11+
image: nginx:alpine:1.25.4
12+
ports:
13+
- "8080:80"
14+
volumes:
15+
- ./nginx.conf:/etc/nginx/nginx.conf
16+
depends-on:
17+
- server
18+
volumes:
19+
myapp_vol: {}

scripts/skel.sh renamed to scripts/setup.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
mvn_skeleton() {
44
mvn archetype:generate \
5-
-DgroupId=com.meucafelist.app \
5+
-DgroupId=com.mycafelist.app \
66
-DartifactId=server \
77
-DarchetypeArtifactId=maven-archetype-quickstart \
88
-DarchetypeVersion=1.0 \
@@ -23,7 +23,11 @@ SPRING_PLUGIN=$(cat <<'EOF'
2323
EOF
2424
)
2525

26-
# todo: fix it to the second ocurrence
27-
sed -i '/</artifactId>/a '"$SPRING_PLUGIN" ./pom.xml
26+
# match second ocurrence of pattern, append SPRING_PLUGIN. cheatsheet below
27+
# t = conditional branch;
28+
# a = append text
29+
# P = prints line from the pattern space until the first newline
30+
#
31+
sed -i "/</artifactId>/!b;:a;\$!N;s/</artifactId>/$SPRING_PLUGIN/2;ta;P;D" ./server/pom.xml
2832

2933
}

0 commit comments

Comments
 (0)