Initial commit
This commit is contained in:
parent
86c0a970f4
commit
2b489f4b22
56
README.md
56
README.md
@ -1,3 +1,57 @@
|
|||||||
# webapp-service-api-stack
|
# webapp-service-api-stack
|
||||||
|
|
||||||
Stack for deploying the webapp service api
|
Stack definition for the webapp api service.
|
||||||
|
|
||||||
|
## Running this stack locally
|
||||||
|
|
||||||
|
(Assumes stack-orchestrator and docker are already installed)
|
||||||
|
|
||||||
|
### Fetch the stack repo
|
||||||
|
|
||||||
|
```
|
||||||
|
$ laconic-so fetch-stack git.vdb.to/cerc-io/webapp-service-api-stack --pull
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clone project repositories
|
||||||
|
|
||||||
|
```
|
||||||
|
$ laconic-so --stack ~/cerc/webapp-service-api-stack/stack-orchestrator/stacks/snowballtools-base-backend setup-repositories --git-ssh --pull
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build service container
|
||||||
|
|
||||||
|
(Might take 10 minutes)
|
||||||
|
|
||||||
|
```
|
||||||
|
$ laconic-so --stack ~/cerc/webapp-service-api-stack/stack-orchestrator/stacks/snowballtools-base-backend build-containers
|
||||||
|
```
|
||||||
|
|
||||||
|
### Create a deployment
|
||||||
|
|
||||||
|
A deployment is a collection of all the stuff needed to run a single instance of a stack, in this case the snowball api service.
|
||||||
|
|
||||||
|
Initialize:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ laconic-so --stack ~/cerc/webapp-service-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy init --output local-deployment-spec.yml --config SNOWBALL_BACKEND_CONFIG_FILE_PATH=/config/local.toml
|
||||||
|
```
|
||||||
|
Then create:
|
||||||
|
```
|
||||||
|
$ laconic-so --stack ~/cerc/webapp-service-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy create --deployment-dir local-deployment --spec-file local-deployment-spec.yml
|
||||||
|
```
|
||||||
|
Next create a file at `local-deployment/data/config/local.toml` with this content:
|
||||||
|
```
|
||||||
|
<redacted>
|
||||||
|
```
|
||||||
|
Finally start the service:
|
||||||
|
```
|
||||||
|
$ laconic-so deployment --dir local-deployment start
|
||||||
|
```
|
||||||
|
To check logs:
|
||||||
|
```
|
||||||
|
$ laconic-so deployment --dir local-deployment logs
|
||||||
|
```
|
||||||
|
To stop the service:
|
||||||
|
```
|
||||||
|
$ laconic-so deployment --dir local-deployment stop
|
||||||
|
```
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
services:
|
||||||
|
snowballtools-base-backend:
|
||||||
|
image: cerc/snowballtools-base-backend:local
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
|
SNOWBALL_BACKEND_CONFIG_FILE_PATH: ${SNOWBALL_BACKEND_CONFIG_FILE_PATH}
|
||||||
|
volumes:
|
||||||
|
- data:/data
|
||||||
|
- config:/config:ro
|
||||||
|
ports:
|
||||||
|
- 8000
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
data:
|
||||||
|
config:
|
@ -0,0 +1,6 @@
|
|||||||
|
FROM cerc/snowballtools-base-backend-base:local
|
||||||
|
|
||||||
|
WORKDIR /app/packages/backend
|
||||||
|
COPY run.sh .
|
||||||
|
|
||||||
|
ENTRYPOINT ["./run.sh"]
|
@ -0,0 +1,26 @@
|
|||||||
|
FROM ubuntu:22.04 as builder
|
||||||
|
|
||||||
|
RUN apt update && \
|
||||||
|
apt install -y --no-install-recommends --no-install-suggests \
|
||||||
|
ca-certificates curl gnupg
|
||||||
|
|
||||||
|
# Node
|
||||||
|
ARG NODE_MAJOR=20
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt update && apt install -y nodejs
|
||||||
|
|
||||||
|
# npm setup
|
||||||
|
RUN npm config set @cerc-io:registry https://git.vdb.to/api/packages/cerc-io/npm/ && npm install -g yarn
|
||||||
|
|
||||||
|
COPY . /app/
|
||||||
|
WORKDIR /app/
|
||||||
|
|
||||||
|
RUN find . -name 'node_modules' | xargs -n1 rm -rf
|
||||||
|
RUN yarn && yarn build --ignore frontend
|
||||||
|
|
||||||
|
FROM cerc/webapp-base:local
|
||||||
|
|
||||||
|
COPY --from=builder /app /app
|
||||||
|
|
||||||
|
WORKDIR /app/packages/backend
|
10
stack-orchestrator/container-build/cerc-snowballtools-base-backend/build.sh
Executable file
10
stack-orchestrator/container-build/cerc-snowballtools-base-backend/build.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build cerc/webapp-deployer-backend
|
||||||
|
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
|
||||||
|
# See: https://stackoverflow.com/a/246128/1701505
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
docker build -t cerc/snowballtools-base-backend-base:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile-base ${CERC_REPO_BASE_DIR}/snowballtools-base
|
||||||
|
docker build -t cerc/snowballtools-base-backend:local ${build_command_args} ${SCRIPT_DIR}
|
19
stack-orchestrator/container-build/cerc-snowballtools-base-backend/run.sh
Executable file
19
stack-orchestrator/container-build/cerc-snowballtools-base-backend/run.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
LACONIC_HOSTED_CONFIG_FILE=${LACONIC_HOSTED_CONFIG_FILE}
|
||||||
|
if [ -z "${LACONIC_HOSTED_CONFIG_FILE}" ]; then
|
||||||
|
if [ -f "/config/laconic-hosted-config.yml" ]; then
|
||||||
|
LACONIC_HOSTED_CONFIG_FILE="/config/laconic-hosted-config.yml"
|
||||||
|
elif [ -f "/config/config.yml" ]; then
|
||||||
|
LACONIC_HOSTED_CONFIG_FILE="/config/config.yml"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "${LACONIC_HOSTED_CONFIG_FILE}" ]; then
|
||||||
|
/scripts/apply-webapp-config.sh $LACONIC_HOSTED_CONFIG_FILE "`pwd`/dist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
/scripts/apply-runtime-env.sh "`pwd`/dist"
|
||||||
|
|
||||||
|
yarn start
|
10
stack-orchestrator/stacks/webapp-service-backend/stack.yml
Normal file
10
stack-orchestrator/stacks/webapp-service-backend/stack.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
version: "1.0"
|
||||||
|
name: webapp-service-backend
|
||||||
|
description: "webapp service backend"
|
||||||
|
repos:
|
||||||
|
- git.vdb.to/cerc-io/snowballtools-base
|
||||||
|
containers:
|
||||||
|
- cerc/webapp-base
|
||||||
|
- cerc/snowballtools-base-backend
|
||||||
|
pods:
|
||||||
|
- snowballtools-base-backend
|
Loading…
Reference in New Issue
Block a user