Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vagrant
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,48 @@ Forum API Microservices

![Software Architecture](docs/imgs/arch.jpeg)

## Vagrant Sample

### Provider - Virtual Box

```mermaid
architecture-beta
group vm(server)[Virtual Machine]

group docker(cloud)[Docker] in vm

service sv1(server)[Service 1] in docker
service sv2(server)[Service 2] in docker
service db1(database)[Database 1] in docker
service db2(database)[Database 2] in docker
service redis(database)[Cache] in docker

sv1:B -- T:db1
sv2:B -- T:db2
sv1:R -- L:redis
sv2:L -- R:redis
```

### Docker without Vagrant

```mermaid
architecture-beta

group docker(cloud)[Docker]

service sv1(server)[Service 1] in docker
service sv2(server)[Service 2] in docker
service db1(database)[Database 1] in docker
service db2(database)[Database 2] in docker
service redis(database)[Cache] in docker

sv1:B -- T:db1
sv2:B -- T:db2
sv1:R -- L:redis
sv2:L -- R:redis
```


## License

MIT
Expand Down
91 changes: 91 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "hashicorp-education/ubuntu-24-04"
config.vm.box_version = "0.1.0"


# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# Disable the default share of the current code directory. Doing this
# provides improved isolation between the vagrant box and your host
# by making sure your Vagrantfile isn't accessible to the vagrant box.
# If you use this you may want to enable additional shared subfolders as
# shown above.
# config.vm.synced_folder ".", "/vagrant", disabled: true

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
config.vm.provision "docker" do |d|
d.run "redis", image: "redis:8", args: "-p 6379:6379"
d.run "mongo", image: "mongo:8", args: "-p 27017:27017"
d.run "jaeger", image: "jaegertracing/all-in-one:1.73.0", args: "-p 16686:16686 -p 14268:14268 -p 14250:14250 -p 9411:9411"
d.run "mongo-express", image: "mongo-express:latest", args: "-p 8081:8081 --link mongo -e ME_CONFIG_MONGODB_SERVER=mongo"
d.build_image "/vagrant/app/auth-service", args: "-t 'auth-service:latest'"
d.build_image "/vagrant/app/user-service", args: "-t 'user-service:latest'"
d.build_image "/vagrant/app/thread-service", args: "-t 'thread-service:latest'"
d.run "auth-service", image: "auth-service:latest", args: "-p 9000:80 --link redis --link mongo --link jaeger"
d.run "user-service", image: "user-service:latest", args: "-p 9001:5000 --link mongo --link jaeger --link redis"
d.run "thread-service", image: "thread-service:latest", args: "-p 9002:80 --link mongo --link jaeger --link redis"
end
end
4 changes: 2 additions & 2 deletions app/auth-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:lts-alpine as build
FROM node:lts-alpine AS build
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile
COPY src/ .
COPY tsconfig.json .
RUN yarn compile

FROM node:lts-alpine as runtime
FROM node:lts-alpine AS runtime
WORKDIR /app
COPY --from=build /app/node_modules/ /app/node_modules
COPY --from=build /app/lib /app/lib
Expand Down
4 changes: 2 additions & 2 deletions app/thread-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 as build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
COPY . .
RUN dotnet publish -c Release -o published

FROM mcr.microsoft.com/dotnet/aspnet:8.0 as runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/published .
ENTRYPOINT [ "dotnet", "ThreadService.dll" ]
4 changes: 2 additions & 2 deletions app/user-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 as build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
COPY . .
RUN dotnet publish -c Release -o published

FROM mcr.microsoft.com/dotnet/aspnet:8.0 as runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/published .
ENTRYPOINT [ "dotnet", "UserService.dll" ]
Loading