-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: added folder for local deployment * fix: dependencies * fix: added basic setup for local deployment of application via script * fix: minor script error * fix: wrong path in script * fix: added docker installation if necessary * fix: test file * fix: change to bash * fix: correct docker installation * fix: added python3 in additio to ython3.11 * fix: execution order * fix: using getReader * fix: node version update and env variables * fix: smaller improvements * fix: added necessary additions for container essentials
- Loading branch information
1 parent
37c101a
commit 9c5d800
Showing
18 changed files
with
1,257 additions
and
58 deletions.
There are no files selected for viewing
134 changes: 134 additions & 0 deletions
134
dapr-distributed-calendar/api-gateway/docker-compose.yml
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,134 @@ | ||
version: '3.8' | ||
services: | ||
############################ | ||
# Node app + Dapr sidecar | ||
############################ | ||
controller: | ||
build: ../node | ||
ports: | ||
- "3000" | ||
- "50001" | ||
depends_on: | ||
- redis | ||
- placement | ||
labels: | ||
- "traefik.enable=true" | ||
- "traefik.http.routers.12factor.rule=Host(`12factor.<ENV-NAME>-<ENV-USER-ID>-02.<ENV-ANIMAL>.<ENV-DOMAIN>`)" | ||
networks: | ||
- dapr-callendar-network | ||
environment: | ||
- EVENT_APP=go-events | ||
controller-dapr: | ||
image: "daprio/daprd:edge" | ||
command: ["./daprd", | ||
"-app-id", "controller", | ||
"-app-port", "3000", | ||
"-placement-host-address", "placement:50006", | ||
"-dapr-http-port", "3500", | ||
"-components-path", "/components"] | ||
volumes: | ||
- "../components/:/components" | ||
depends_on: | ||
- controller | ||
network_mode: "service:controller" | ||
############################ | ||
# Python app + Dapr sidecar | ||
############################ | ||
messages: | ||
build: ../python | ||
depends_on: | ||
- redis | ||
- placement | ||
networks: | ||
- dapr-callendar-network | ||
environment: | ||
- FLASK_RUN_PORT=5000 | ||
messages-dapr: | ||
image: "daprio/daprd:edge" | ||
command: ["./daprd", | ||
"-app-id", "messages", | ||
"-app-port", "5000", | ||
"-dapr-http-port", "3501", | ||
"-placement-host-address", "placement:50006", | ||
"-components-path", "/components"] | ||
volumes: | ||
- "../components/:/components" | ||
depends_on: | ||
- messages | ||
network_mode: "service:messages" | ||
############################ | ||
# Go app + Dapr sidecar | ||
############################ | ||
go-events: | ||
build: ../go | ||
environment: | ||
- DAPR_HTTP_PORT=3503 | ||
depends_on: | ||
- redis | ||
- placement | ||
networks: | ||
- dapr-callendar-network | ||
go-events-dapr: | ||
image: "daprio/daprd:edge" | ||
command: ["./daprd", | ||
"-app-id", "go-events", | ||
"-app-port", "6000", | ||
"-placement-host-address", "placement:50006", | ||
"-dapr-http-port", "3503", | ||
"-components-path", "/components"] | ||
volumes: | ||
- "../components/:/components" | ||
depends_on: | ||
- go-events | ||
network_mode: "service:go-events" | ||
############################ | ||
# Dapr placement service | ||
############################ | ||
placement: | ||
image: "daprio/dapr" | ||
command: ["./placement", "-port", "50006"] | ||
ports: | ||
- "50006:50006" | ||
networks: | ||
- dapr-callendar-network | ||
############################ | ||
# Redis state store | ||
############################ | ||
redis: | ||
image: docker.io/bitnami/redis:7.2 | ||
environment: | ||
# ALLOW_EMPTY_PASSWORD is recommended only for development. | ||
# - ALLOW_EMPTY_PASSWORD=yes | ||
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL | ||
- REDIS_PASSWORD=Pa55w.rd | ||
ports: | ||
- '6379' | ||
networks: | ||
- dapr-callendar-network | ||
volumes: | ||
- 'redis_data:/bitnami/redis/data' | ||
############################ | ||
# traefik api gateway | ||
############################ | ||
traefik: | ||
image: traefik:v2.9 | ||
command: | ||
- "--api.insecure=true" # Don't do that in production! | ||
- "--providers.docker=true" | ||
- "--providers.docker.exposedbydefault=false" | ||
ports: | ||
# The HTTP port | ||
- "80:80" | ||
# The Web UI (enabled by --api.insecure=true) | ||
- "8080:8080" | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock:ro | ||
networks: | ||
- dapr-callendar-network | ||
- default | ||
|
||
volumes: | ||
redis_data: | ||
driver: local | ||
networks: | ||
dapr-callendar-network: |
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
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
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,69 @@ | ||
#!/bin/bash | ||
|
||
# Check if Docker is installed | ||
if command -v docker &>/dev/null; then | ||
echo "Docker is already installed." | ||
else | ||
# Install Docker | ||
echo "Docker is not installed. Installing..." | ||
|
||
# Update package index | ||
sudo apt-get update | ||
|
||
# Install Docker | ||
sudo apt install docker.io | ||
|
||
# Add User to docker Group | ||
sudo usermod -aG docker $USER | ||
echo "Docker has been installed. Rerun the script to continue!" | ||
newgrp docker | ||
fi | ||
|
||
# Prepare Dapr environment | ||
cd $HOME | ||
mkdir $HOME/.dapr | ||
cp -r ~/12-factor-app/dapr-distributed-calendar/local/components ~/.dapr | ||
|
||
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash | ||
dapr init # to initialize dapr | ||
|
||
# Prepare Golang environment | ||
git clone https://github.com/udhos/update-golang | ||
cd update-golang | ||
sudo ./update-golang.sh | ||
source /etc/profile.d/golang_path.sh | ||
|
||
# Build Golang application | ||
cd ~/12-factor-app/dapr-distributed-calendar/go | ||
go build go_events.go | ||
|
||
# Prepare Python environment | ||
if command -v python3 &>/dev/null; then | ||
echo "Python 3 is installed on this machine." | ||
else | ||
echo "Python 3 is not installed. Installing..." | ||
sudo apt update | ||
sudo apt install python3 | ||
python3 --version | ||
fi | ||
# Check if python3.11 is available in the PATH | ||
if command -v python3.11 &>/dev/null; then | ||
echo "Python 3.11 is installed on this machine." | ||
else | ||
echo "Python 3.11 is not installed. Installing..." | ||
sudo apt update | ||
sudo apt install python3.11 | ||
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 | ||
python3 --version | ||
fi | ||
|
||
# Install Python Requirements | ||
cd ~/12-factor-app/dapr-distributed-calendar/python | ||
pip3 install -r ./requirements.txt | ||
|
||
# Prepare Node environment | ||
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt-get install -y nodejs | ||
|
||
# Install Node Requirements | ||
cd ~/12-factor-app/dapr-distributed-calendar/node | ||
npm install |
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,12 @@ | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: pubsub | ||
spec: | ||
type: pubsub.redis | ||
version: v1 | ||
metadata: | ||
- name: redisHost | ||
value: localhost:6379 | ||
- name: redisPassword | ||
value: "" |
14 changes: 14 additions & 0 deletions
14
dapr-distributed-calendar/local/components/statestore.yaml
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,14 @@ | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: events | ||
spec: | ||
type: state.redis | ||
version: v1 | ||
metadata: | ||
- name: redisHost | ||
value: localhost:6379 | ||
- name: redisPassword | ||
value: "" | ||
- name: actorStateStore | ||
value: "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
FROM node:17-alpine | ||
FROM node:18-alpine | ||
|
||
WORKDIR /app | ||
COPY . . | ||
RUN npm install | ||
RUN npm install @opentelemetry/api @opentelemetry/resources \ | ||
@opentelemetry/semantic-conventions \ | ||
@opentelemetry/sdk-node \ | ||
@opentelemetry/sdk-metrics\ | ||
@opentelemetry/exporter-metrics-otlp-grpc | ||
|
||
EXPOSE 3000 | ||
CMD [ "node", "--require", "./instrumentation.js", "node_controller.js"] |
Oops, something went wrong.