-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump dependencies +
devcontainer
+ Makefile
+ node-service
impr…
…ovement (#30) * Fix Node.js 16 actions are deprecated. * Optimize node-service's container image * Fix CVEs: mysql2 3.9.7 * Add devcontainer for node-service and podinfo * score-compose for node-service * node-service - add MESSAGE and MySQL version/host * Fix node-service workload versus container names * Clarify App versus Workload versus Container names
- Loading branch information
1 parent
e65b325
commit 88178c8
Showing
15 changed files
with
228 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
templates/node-service/content/.devcontainer/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "Score & Humanitec Dev Container", | ||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
"moby": true, | ||
"version": "latest" | ||
}, | ||
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { | ||
"version": "latest", | ||
"helm": "latest", | ||
"minikube": "latest" | ||
} | ||
}, | ||
"postCreateCommand": "bash .devcontainer/installMoreTools.sh", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"redhat.vscode-yaml" | ||
], | ||
"settings": { | ||
"yaml.schemas": { | ||
"https://raw.githubusercontent.com/score-spec/schema/main/score-v1b1.json": "score.yaml" | ||
} | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
templates/node-service/content/.devcontainer/installMoreTools.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
mkdir install-more-tools | ||
cd install-more-tools | ||
|
||
SCORE_COMPOSE_VERSION=$(curl -sL https://api.github.com/repos/score-spec/score-compose/releases/latest | jq -r .tag_name) | ||
wget https://github.com/score-spec/score-compose/releases/download/${SCORE_COMPOSE_VERSION}/score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz | ||
tar -xvf score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz | ||
chmod +x score-compose | ||
sudo mv score-compose /usr/local/bin | ||
|
||
HUMCTL_VERSION=$(curl -sL https://api.github.com/repos/humanitec/cli/releases/latest | jq -r .tag_name) | ||
curl -fLO https://github.com/humanitec/cli/releases/download/${HUMCTL_VERSION}/cli_${HUMCTL_VERSION:1}_linux_amd64.tar.gz | ||
tar -xvf cli_${HUMCTL_VERSION:1}_linux_amd64.tar.gz | ||
chmod +x humctl | ||
sudo mv humctl /usr/local/bin/humctl | ||
|
||
KIND_VERSION=$(curl -sL https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r .tag_name) | ||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64 | ||
chmod +x ./kind | ||
sudo mv ./kind /usr/local/bin/kind | ||
|
||
cd .. | ||
rm -rf install-more-tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
node_modules/ | ||
compose.yaml | ||
values.yaml | ||
.score-compose/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
FROM alpine:3.18.3 | ||
|
||
# Install nodejs | ||
FROM alpine:3.19.1 as builder | ||
RUN apk add --no-cache nodejs npm | ||
|
||
COPY package*.json ./ | ||
RUN npm install | ||
RUN npm install --only=prod | ||
|
||
FROM alpine:3.19.1 | ||
RUN apk add --no-cache nodejs | ||
COPY --from=builder /node_modules ./node_modules | ||
COPY index.js index.js | ||
|
||
# Expose port 3000 | ||
EXPOSE 3000 | ||
|
||
# Run the app | ||
CMD ["node", "index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Disable all the default make stuff | ||
MAKEFLAGS += --no-builtin-rules | ||
.SUFFIXES: | ||
|
||
## Display a list of the documented make targets | ||
.PHONY: help | ||
help: | ||
@echo Documented Make targets: | ||
@perl -e 'undef $$/; while (<>) { while ($$_ =~ /## (.*?)(?:\n# .*)*\n.PHONY:\s+(\S+).*/mg) { printf "\033[36m%-30s\033[0m %s\n", $$2, $$1 } }' $(MAKEFILE_LIST) | sort | ||
|
||
.PHONY: .FORCE | ||
.FORCE: | ||
|
||
WORKLOAD_NAME = node-workload | ||
CONTAINER_NAME = node-service | ||
CONTAINER_IMAGE = ${CONTAINER_NAME}:test | ||
|
||
compose.yaml: score.yaml | ||
score-compose init \ | ||
--no-sample | ||
score-compose generate score.yaml \ | ||
--build '${CONTAINER_NAME}={"context":".","tags":["${CONTAINER_IMAGE}"]}' \ | ||
--override-property containers.${CONTAINER_NAME}.variables.MESSAGE="Hello, Compose!" | ||
|
||
## Generate a compose.yaml file from the score spec and launch it. | ||
.PHONY: compose-up | ||
compose-up: compose.yaml | ||
docker compose up --build -d --remove-orphans | ||
|
||
## Generate a compose.yaml file from the score spec, launch it and test (curl) the exposed container. | ||
.PHONY: compose-test | ||
compose-test: compose-up | ||
sleep 5 | ||
curl $$(score-compose resources get-outputs dns.default#${WORKLOAD_NAME}.dns --format '{{ .host }}:8080') | ||
|
||
## Delete the containers running via compose down. | ||
.PHONY: compose-down | ||
compose-down: | ||
docker compose down -v --remove-orphans || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
"license": "PRIVATE", | ||
"private": true, | ||
"dependencies": { | ||
"mysql2": "^3.6.0" | ||
"mysql2": "^3.9.7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
templates/podinfo-example/content/.devcontainer/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "Score & Humanitec Dev Container", | ||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
"moby": true, | ||
"version": "latest" | ||
}, | ||
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { | ||
"version": "latest", | ||
"helm": "latest", | ||
"minikube": "latest" | ||
} | ||
}, | ||
"postCreateCommand": "bash .devcontainer/installMoreTools.sh", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"redhat.vscode-yaml" | ||
], | ||
"settings": { | ||
"yaml.schemas": { | ||
"https://raw.githubusercontent.com/score-spec/schema/main/score-v1b1.json": "score.yaml" | ||
} | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
templates/podinfo-example/content/.devcontainer/installMoreTools.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
mkdir install-more-tools | ||
cd install-more-tools | ||
|
||
SCORE_COMPOSE_VERSION=$(curl -sL https://api.github.com/repos/score-spec/score-compose/releases/latest | jq -r .tag_name) | ||
wget https://github.com/score-spec/score-compose/releases/download/${SCORE_COMPOSE_VERSION}/score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz | ||
tar -xvf score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz | ||
chmod +x score-compose | ||
sudo mv score-compose /usr/local/bin | ||
|
||
HUMCTL_VERSION=$(curl -sL https://api.github.com/repos/humanitec/cli/releases/latest | jq -r .tag_name) | ||
curl -fLO https://github.com/humanitec/cli/releases/download/${HUMCTL_VERSION}/cli_${HUMCTL_VERSION:1}_linux_amd64.tar.gz | ||
tar -xvf cli_${HUMCTL_VERSION:1}_linux_amd64.tar.gz | ||
chmod +x humctl | ||
sudo mv humctl /usr/local/bin/humctl | ||
|
||
KIND_VERSION=$(curl -sL https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r .tag_name) | ||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64 | ||
chmod +x ./kind | ||
sudo mv ./kind /usr/local/bin/kind | ||
|
||
cd .. | ||
rm -rf install-more-tools |
Oops, something went wrong.