diff --git a/Tiltfile b/Tiltfile index a396b33f..bbd72d52 100644 --- a/Tiltfile +++ b/Tiltfile @@ -17,6 +17,7 @@ docker_compose([ "./docker-compose.dotnet.yml", "./docker-compose.python.yml", "./docker-compose.web.yml", + "./docker-compose.elixir.yml", "./docker-compose.node.yml"]) # populate redis for message services that use redis @@ -108,41 +109,6 @@ def launch_ruby_name_service(auto_init=True): def launch_ruby_year_service(auto_init=True): launch_ruby_svc("year-rb", "ruby/year-service", "puma --port 6001", auto_init=auto_init) -def launch_elixir_svc(name, dirname="", cmd="", auto_init=True): - ''' - Starts a single Elixir service. - - Parameters: - name: used to display the name of the process in the tilt tab - dirname: (optional) directory name in which to run the app defaults to 'name' - flags: (optional) any additional flags to add to the command line - - ''' - - # env = {'SERVICE_NAME': name} - - setup_cmd = "cd {} && mix local.hex --force && mix local.rebar --force && mix deps.get && mix deps.compile".format( - dirname if dirname else name, - ) - serve_cmd = "cd {} && mix {}".format(dirname, cmd) - - if "elixir" in to_run or name in to_run: - print("About to start {} with command {}".format(name, serve_cmd)) - - local_resource(name, setup_cmd, auto_init=auto_init, serve_cmd=serve_cmd) - -def launch_elixir_frontend(auto_init=True): - launch_elixir_svc("frontend-elixir", dirname="elixir/frontend", cmd="phx.server", auto_init=auto_init) - -def launch_elixir_message_service(auto_init=True): - launch_elixir_svc("message-elixir", dirname="elixir/message", cmd="run --no-halt", auto_init=auto_init) - -def launch_elixir_name_service(auto_init=True): - launch_elixir_svc("name-elixir", dirname="elixir/name", cmd="run --no-halt", auto_init=auto_init) - -def launch_elixir_year_service(auto_init=True): - launch_elixir_svc("year-elixir", dirname="elixir/year", cmd="run --no-halt", auto_init=auto_init) - # Launch all services so that all service resources are registered with Tilt # Other services use docker @@ -150,19 +116,15 @@ def launch_elixir_year_service(auto_init=True): # Server services launch_go_frontend() launch_ruby_frontend() -launch_elixir_frontend() launch_go_message_service() launch_ruby_message_service() -launch_elixir_message_service() launch_go_name_service() launch_ruby_name_service() -launch_elixir_name_service() launch_go_year_service() launch_ruby_year_service() -launch_elixir_year_service() # Create map of "groups" of services to commonly run together (e.g. all node services) supported_languages = ["go", "python", "rb", "java", "dotnet", "node", "elixir"] diff --git a/docker-compose.elixir.yml b/docker-compose.elixir.yml new file mode 100644 index 00000000..cea4f08c --- /dev/null +++ b/docker-compose.elixir.yml @@ -0,0 +1,56 @@ +version: "2.4" + +# noinspection ComposeUnknownKeys +x-common-env: &common-env + HONEYCOMB_API_KEY: + HONEYCOMB_DATASET: + HONEYCOMB_API: + OTEL_EXPORTER_OTLP_ENDPOINT: + OTEL_EXPORTER_OTLP_HEADERS: + OTEL_RESOURCE_ATTRIBUTES: app.running-in=docker + MESSAGE_ENDPOINT: message-service:9000 + NAME_ENDPOINT: name-service:8000 + YEAR_ENDPOINT: year-service:6001 + REDIS_URL: redis + OTEL_COLLECTOR_HOST: collector + +services: + frontend-elixir: + container_name: frontend-service + build: ./elixir/frontend + image: hnyexample/frontend-elixir + environment: + <<: *common-env + OTEL_SERVICE_NAME: frontend-elixir + ports: + - 7777:7777 + + message-elixir: + container_name: message-service + build: ./elixir/message + image: hnyexample/message-elixir + environment: + <<: *common-env + SERVICE_NAME: message-elixir + ports: + - 9000:9000 + + name-elixir: + container_name: name-service + build: ./elixir/name + image: hnyexample/name-elixir + environment: + <<: *common-env + SERVICE_NAME: name-elixir + ports: + - 8000:8000 + + year-elixir: + container_name: year-service + build: ./elixir/year + image: hnyexample/year-elixir + environment: + <<: *common-env + SERVICE_NAME: year-elixir + ports: + - 6001:6001 diff --git a/elixir/README.md b/elixir/README.md index 0077eb65..4a4931ba 100644 --- a/elixir/README.md +++ b/elixir/README.md @@ -6,7 +6,9 @@ - Name: Service that chooses a random name. - Year: Service that returns a random year. -## How to run +## How to run without Tilt/Docker + +See top-level README.md for instructions on how to run services with Tilt and Docker (easiest). ### Install Elixir If using option 1 or 3 below, make sure you have Elixir installed. The preferred way to install Elixir is with [asdf](https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies). @@ -26,7 +28,7 @@ asdf install erlang asdf install elixir ``` -### Option 1: One service at a time +### Run each service Install dependencies in the service directory @@ -48,14 +50,6 @@ Message/Name/Year: mix run --no-halt ``` -### Option 2: All Elixir Services via Docker - -In the Elixir directory run `docker-compose up -- build`. - -### Option 3: All Elixir Servies via Tilt - -In the top level directory run `tilt up elixir` - ## See it in action `curl localhost:7777/greeting` for greeting diff --git a/elixir/docker-compose.yml b/elixir/docker-compose.yml deleted file mode 100644 index 5acf8a70..00000000 --- a/elixir/docker-compose.yml +++ /dev/null @@ -1,36 +0,0 @@ -services: - collector: - extends: - file: ../docker-compose.yml - service: collector - - year: - build: year - environment: - - OTEL_COLLECTOR_HOST=collector - ports: - - "6001:6001" - - frontend: - build: frontend - environment: - - NAME_ENDPOINT=name:8000 - - MESSAGE_ENDPOINT=message:9000 - - OTEL_COLLECTOR_HOST=collector - ports: - - "7777:7777" - - name: - build: name - environment: - - YEAR_ENDPOINT=year:6001 - - OTEL_COLLECTOR_HOST=collector - ports: - - "8000:8000" - - message: - build: message - environment: - - OTEL_COLLECTOR_HOST=collector - ports: - - "9000:9000"