-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SberMarket-Tech/feat/initial
Initial commit
- Loading branch information
Showing
218 changed files
with
6,219 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Quest | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ '**' ] | ||
|
||
jobs: | ||
lint: | ||
name: Rubocop | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./quest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup Ruby w/ same version as image | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "3.3" | ||
- name: Install dependencies | ||
run: | | ||
docker network create infranet | ||
gem install dip | ||
dip bundle install | ||
- name: Run linter | ||
run: dip rubocop | ||
|
||
test: | ||
name: Rspec | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./quest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup Ruby w/ same version as image | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "3.3" | ||
- name: Install dependencies | ||
run: | | ||
docker network create infranet | ||
gem install dip | ||
dip provision | ||
- name: Run tests | ||
run: dip rspec --format RspecJunitFormatter --out test-results/rspec.xml --format documentation |
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,50 @@ | ||
name: Voyage | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ '**' ] | ||
|
||
jobs: | ||
lint: | ||
name: Rubocop | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./voyage | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup Ruby w/ same version as image | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "3.3" | ||
- name: Install dependencies | ||
run: | | ||
docker network create infranet | ||
gem install dip | ||
dip bundle install | ||
- name: Run linter | ||
run: dip rubocop | ||
|
||
test: | ||
name: Rspec | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./voyage | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup Ruby w/ same version as image | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "3.3" | ||
- name: Install dependencies | ||
run: | | ||
docker network create infranet | ||
gem install dip | ||
dip provision | ||
- name: Run tests | ||
run: dip rspec --format RspecJunitFormatter --out test-results/rspec.xml --format documentation |
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,36 @@ | ||
# outbox-example-apps | ||
# Outbox example apps | ||
|
||
These are example applications that use: | ||
- [sbmt-outbox](https://github.com/SberMarket-Tech/sbmt-outbox) | ||
- [sbmt-kafka_producer](https://github.com/SberMarket-Tech/sbmt-kafka_producer) | ||
- [sbmt-kafka_consumer](https://github.com/SberMarket-Tech/sbmt-kafka_consumer) | ||
|
||
## How to run | ||
|
||
1. Install [Dip](https://github.com/bibendi/dip) | ||
2. Start [Kafka](./infra/) broker `cd infra && dip up` | ||
3. Start [Quest](./quest/) application `cd quest && dip up` | ||
4. Start [Voyage](./voyage/) application `cd voyage && dip up` | ||
|
||
## Test case | ||
|
||
1. Create an order in Quest app | ||
|
||
```shell | ||
curl --location http://localhost:3000/api/v1/orders \ | ||
--form '[order]name=Foo' \ | ||
--form '[order]qty=3' \ | ||
--form '[order]price=42' | ||
``` | ||
|
||
2. Send the order to Vayage app through Outbox pattern | ||
|
||
```shell | ||
curl --request POST --location http://localhost:3000/api/v1/orders/<ORDER-UUID>/completion | ||
``` | ||
|
||
3. Show the imported order | ||
|
||
```shell | ||
curl --location http://localhost:3001/api/v1/orders | ||
``` |
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,22 @@ | ||
version: '7.5' | ||
|
||
compose: | ||
files: | ||
- docker-compose.yml | ||
|
||
interaction: | ||
bash: | ||
description: Open a Bash shell | ||
service: kafka | ||
command: bash | ||
|
||
kafka: | ||
description: Kafka scripts, see more at https://kafka.apache.org/documentation | ||
service: kafka | ||
subcommands: | ||
topics: | ||
command: kafka-topics.sh --bootstrap-server kafka:9092 | ||
consumer: | ||
command: kafka-console-consumer.sh --bootstrap-server kafka:9092 | ||
consumer-groups: | ||
command: kafka-consumer-groups.sh --bootstrap-server kafka:9092 |
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,40 @@ | ||
services: | ||
zookeeper: | ||
image: bitnami/zookeeper:3.9 | ||
environment: | ||
ALLOW_ANONYMOUS_LOGIN: "yes" | ||
volumes: | ||
- zookeeper:/bitnami | ||
ports: | ||
- 2181 | ||
networks: | ||
- default | ||
- infranet | ||
|
||
kafka: | ||
image: bitnami/kafka:3.6 | ||
depends_on: | ||
- zookeeper | ||
environment: | ||
ALLOW_PLAINTEXT_LISTENER: "yes" | ||
KAFKA_ENABLE_KRAFT: "no" | ||
KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper:2181 | ||
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 | ||
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094 | ||
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT | ||
volumes: | ||
- kafka:/data | ||
ports: | ||
- 9092 | ||
- 9094 | ||
networks: | ||
- default | ||
- infranet | ||
|
||
volumes: | ||
zookeeper: | ||
kafka: | ||
|
||
networks: | ||
infranet: | ||
name: infranet |
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,23 @@ | ||
-- Don't display the "helpful" message on startup. | ||
\set QUIET 1 | ||
|
||
-- psql writes to a temporary file before then moving that temporary file on top of the old history file | ||
-- a bind mount of a file only bind mounts the inode, so a rename like this won't ever work | ||
\set HISTFILE /var/log/psql_history/.psql_history | ||
|
||
-- Use best available output format | ||
\x auto | ||
|
||
-- Verbose error reports | ||
\set VERBOSITY verbose | ||
|
||
-- If a command is run more than once in a row, | ||
-- only store it once in the history | ||
\set HISTCONTROL ignoredups | ||
\set COMP_KEYWORD_CASE upper | ||
|
||
-- By default, NULL displays as an empty space. Is it actually an empty | ||
-- string, or is it null? This makes that distinction visible | ||
\pset null '[NULL]' | ||
|
||
\unset QUIET |
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,55 @@ | ||
ARG BASE_IMAGE | ||
|
||
FROM ${BASE_IMAGE} | ||
|
||
ARG POSTGRES_VERSION | ||
ARG RUBYGEMS_VERSION | ||
ARG BUNDLER_VERSION | ||
|
||
ENV RAILS_ENV=development | ||
|
||
# Common dependencies | ||
RUN apt-get update -qq \ | ||
&& apt-get dist-upgrade -y \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ | ||
build-essential \ | ||
gnupg2 \ | ||
pkg-config \ | ||
ca-certificates \ | ||
curl \ | ||
wget \ | ||
less \ | ||
git \ | ||
vim \ | ||
shared-mime-info \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/cache/apt/archives/* \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ | ||
&& truncate -s 0 /var/log/*log | ||
|
||
|
||
# Postgres client | ||
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgres-archive-keyring.gpg \ | ||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/postgres-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt/" bookworm-pgdg main $POSTGRES_VERSION | tee /etc/apt/sources.list.d/postgres.list > /dev/null | ||
|
||
# App's dependencies | ||
RUN apt-get update -qq \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ | ||
postgresql-client-${POSTGRES_VERSION} \ | ||
libpq-dev \ | ||
file \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/cache/apt/archives/* \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ | ||
&& truncate -s 0 /var/log/*log | ||
|
||
# Bundler | ||
ENV LANG=C.UTF-8 \ | ||
BUNDLE_JOBS=4 \ | ||
BUNDLE_RETRY=3 | ||
RUN gem update --system ${RUBYGEMS_VERSION} \ | ||
&& gem install --default bundler -v ${BUNDLER_VERSION} | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["/usr/bin/bash"] |
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,112 @@ | ||
x-environments: &environments | ||
HISTFILE: /app/log/.bash_history | ||
EDITOR: vim | ||
prometheus_multiproc_dir: ./tmp | ||
BUNDLE_APP_CONFIG: ../.bundle | ||
DATABASE_URL: postgres://postgres:keepinsecret@postgres:5432 | ||
REDIS_URL: redis://redis:6379 | ||
KAFKA_BROKERS: kafka.infranet:9092 | ||
|
||
x-ruby: &ruby | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
args: | ||
# Keep in sync with Gitlab CI configs | ||
BASE_IMAGE: ruby:3.3-bookworm | ||
POSTGRES_VERSION: '16' | ||
RUBYGEMS_VERSION: '3.5.6' | ||
BUNDLER_VERSION: '2.5.5' | ||
image: quest-dev:1.0.0 | ||
environment: | ||
<<: *environments | ||
tmpfs: | ||
- /tmp | ||
stdin_open: true | ||
tty: true | ||
working_dir: ${WORK_DIR:-/app} | ||
volumes: | ||
- ../..:/gems:cached | ||
- ..:/app:cached | ||
- .psqlrc:/root/.psqlrc:ro | ||
# We store Rails cache and gems in volumes to get speed up on Docker for Mac | ||
- rails_cache:/app/tmp/cache | ||
- bundle:/usr/local/bundle | ||
networks: | ||
- default | ||
- infranet | ||
|
||
x-rails-deps: &rails-deps | ||
postgres: | ||
condition: service_healthy | ||
redis: | ||
condition: service_healthy | ||
|
||
x-rails: &rails | ||
<<: *ruby | ||
depends_on: | ||
<<: *rails-deps | ||
|
||
name: quest | ||
|
||
services: | ||
backend: | ||
<<: *rails | ||
command: /bin/bash | ||
profiles: | ||
- donotstart | ||
|
||
puma: | ||
<<: *rails | ||
command: bundle exec puma | ||
ports: | ||
- '3000:3000' | ||
|
||
sidekiq: | ||
<<: *rails | ||
command: bundle exec sidekiq -C config/sidekiq.yml | ||
|
||
schked: | ||
<<: *rails | ||
command: bundle exec schked start | ||
|
||
outbox: | ||
<<: *rails | ||
command: bundle exec outbox start | ||
|
||
postgres: | ||
image: postgres:16-bookworm | ||
volumes: | ||
- postgres:/var/lib/postgresql/data | ||
- .psqlrc:/root/.psqlrc:ro | ||
- ../log:/var/log/psql_history | ||
ports: | ||
- 5432 | ||
environment: | ||
POSTGRES_PASSWORD: keepinsecret | ||
healthcheck: | ||
test: pg_isready -U postgres -h 127.0.0.1 | ||
interval: 10s | ||
|
||
redis: | ||
image: redis:7-bookworm | ||
environment: | ||
ALLOW_EMPTY_PASSWORD: "yes" | ||
volumes: | ||
- redis:/data | ||
ports: | ||
- 6379 | ||
healthcheck: | ||
test: redis-cli ping | ||
interval: 10s | ||
|
||
volumes: | ||
bundle: | ||
postgres: | ||
redis: | ||
rails_cache: | ||
|
||
networks: | ||
infranet: | ||
name: infranet | ||
external: true |
Oops, something went wrong.