From 8c0074079f1c7bf93eff8df4e1b26022fe5bad19 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 11 May 2022 16:47:47 +0200 Subject: [PATCH 1/6] Update app to .NET6 --- opbeans-dotnet/Controllers/ProductsController.cs | 2 +- opbeans-dotnet/Data/Seed.cs | 2 +- opbeans-dotnet/Startup.cs | 16 ++++++++++------ opbeans-dotnet/appsettings.Development.json | 6 +++--- opbeans-dotnet/appsettings.json | 2 +- opbeans-dotnet/opbeans-dotnet.csproj | 7 ++++--- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/opbeans-dotnet/Controllers/ProductsController.cs b/opbeans-dotnet/Controllers/ProductsController.cs index ae7242f..67b4d15 100644 --- a/opbeans-dotnet/Controllers/ProductsController.cs +++ b/opbeans-dotnet/Controllers/ProductsController.cs @@ -21,7 +21,7 @@ public ActionResult> Get() => [HttpGet("top")] public ActionResult> Top() => - _dbDbContext.Products.FromSql(@"SELECT + _dbDbContext.Products.FromSqlRaw(@"SELECT products.id, sku, name, description, cost, selling_price, stock, type_id , SUM(order_lines.amount) AS sold FROM products JOIN order_lines ON products.id=product_id GROUP BY products.id ORDER BY sold DESC") .Select(n => Mapper.Map(n)).ToList(); diff --git a/opbeans-dotnet/Data/Seed.cs b/opbeans-dotnet/Data/Seed.cs index eb38a04..fc92c11 100644 --- a/opbeans-dotnet/Data/Seed.cs +++ b/opbeans-dotnet/Data/Seed.cs @@ -10,7 +10,7 @@ public static class Seed //without a primary key I added 'id INTEGER PRIMARY KEY AUTOINCREMENT' to the `order_lines` table. Other than that //this is the default sql script. public static void SeedDb(OpbeansDbContext dbDbContext) => - dbDbContext.Database.ExecuteSqlCommand( + dbDbContext.Database.ExecuteSqlRaw( @" -- Drop everything DROP TABLE IF EXISTS 'products'; diff --git a/opbeans-dotnet/Startup.cs b/opbeans-dotnet/Startup.cs index 1b25c9d..5dc35c2 100644 --- a/opbeans-dotnet/Startup.cs +++ b/opbeans-dotnet/Startup.cs @@ -36,7 +36,14 @@ public void ConfigureServices(IServiceCollection services) Seed.SeedDb(context); services.AddDbContext - (options => options.UseSqlite(@"Data Source=opbeans.db")); + (options => + { + options.UseSqlite(@"Data Source=opbeans.db"); + // This is a sample app with a sample dummy db + // it's fine to log any data, it's better for debugging. + options.EnableSensitiveDataLogging(); + } + ); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -62,7 +69,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) var dtProbabilityEnvVar = Environment.GetEnvironmentVariable("OPBEANS_DT_PROBABILITY"); if (!double.TryParse(dtProbabilityEnvVar, NumberStyles.Float, CultureInfo.InvariantCulture, - out var dtProbability)) + out var dtProbability)) dtProbability = 0.5; var random = new Random(DateTime.UtcNow.Millisecond); @@ -115,10 +122,7 @@ await httpClient.GetAsync( app.UseHttpsRedirection(); app.UseRouting(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); + app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } private static List KnownApis => diff --git a/opbeans-dotnet/appsettings.Development.json b/opbeans-dotnet/appsettings.Development.json index 331805c..e27bf6f 100644 --- a/opbeans-dotnet/appsettings.Development.json +++ b/opbeans-dotnet/appsettings.Development.json @@ -1,9 +1,9 @@ { "Logging": { "LogLevel": { - "Default": "Debug", - "System": "Debug", - "Microsoft": "Debug" + "Default": "Trace", + "System": "Trace", + "Microsoft": "Trace" } } } diff --git a/opbeans-dotnet/appsettings.json b/opbeans-dotnet/appsettings.json index 02a63ab..89ffafc 100644 --- a/opbeans-dotnet/appsettings.json +++ b/opbeans-dotnet/appsettings.json @@ -1,7 +1,7 @@ { "Logging": { "LogLevel": { - "Default": "Debug" + "Default": "Trace" } }, "ElasticApm": diff --git a/opbeans-dotnet/opbeans-dotnet.csproj b/opbeans-dotnet/opbeans-dotnet.csproj index 5b5f548..90266c1 100644 --- a/opbeans-dotnet/opbeans-dotnet.csproj +++ b/opbeans-dotnet/opbeans-dotnet.csproj @@ -1,15 +1,16 @@  - netcoreapp3.1 + net6.0 InProcess OpbeansDotnet - - + + + From e0267f62c05a219da8d4a1f516fe63a67df9d444 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 11 May 2022 16:48:52 +0200 Subject: [PATCH 2/6] Remove unused files --- Dockerfile | 23 ----- Makefile | 36 -------- docker-compose-elastic-cloud.yml | 95 -------------------- docker-compose.yml | 147 ------------------------------- 4 files changed, 301 deletions(-) delete mode 100644 Dockerfile delete mode 100644 Makefile delete mode 100644 docker-compose-elastic-cloud.yml delete mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d95ec91..0000000 --- a/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build -COPY . /src/ - -WORKDIR /src -RUN dotnet restore -RUN dotnet publish -c Release -o out - -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.7-alpine AS runtime -WORKDIR /app -COPY --from=build /src/out ./ -COPY --from=opbeans/opbeans-frontend:latest /app/build /opbeans-frontend - -LABEL \ - org.label-schema.schema-version="1.0" \ - org.label-schema.vendor="Elastic" \ - org.label-schema.name="opbeans-dotnet" \ - org.label-schema.version="1.11.1" \ - org.label-schema.url="https://hub.docker.com/r/opbeans/opbeans-dotnet" \ - org.label-schema.vcs-url="https://github.com/elastic/opbeans-dotnet" \ - org.label-schema.license="MIT" - -EXPOSE 80 -ENTRYPOINT ["dotnet", "opbeans-dotnet.dll"] diff --git a/Makefile b/Makefile deleted file mode 100644 index b0b77f0..0000000 --- a/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -PORT ?= 80 -IMAGE ?= opbeans/opbeans-dotnet -VERSION ?= latest -LTS_ALPINE ?= 12-alpine - -.PHONY: help -.DEFAULT_GOAL := help - -help: ## Display this help text - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' - -all: build test - -build: ## Build docker image - @docker build --file Dockerfile --tag=${IMAGE}:${VERSION} . - -bats: ## Install bats in the project itself - @git clone https://github.com/sstephenson/bats.git - -prepare-test: bats ## Prepare the bats dependencies - @docker pull node:${LTS_ALPINE} - @mkdir -p target - @git submodule sync - @git submodule update --init --recursive - -test: prepare-test ## Run the tests - @bats/bin/bats --tap tests | tee target/results.tap - @docker run --rm -v "${PWD}":/usr/src/app -w /usr/src/app node:${LTS_ALPINE} \ - sh -c "npm install tap-xunit -g && cat target/results.tap | tap-xunit --package='co.elastic.opbeans' > target/junit-results.xml" - -publish: build ## Publish docker image - @docker push "${IMAGE}:${VERSION}" - -clean: ## Clean autogenerated files/folders - @rm -rf bats - @rm -rf target diff --git a/docker-compose-elastic-cloud.yml b/docker-compose-elastic-cloud.yml deleted file mode 100644 index 8886424..0000000 --- a/docker-compose-elastic-cloud.yml +++ /dev/null @@ -1,95 +0,0 @@ -version: "2.1" -services: - opbeans-dotnet: - build: . - image: opbeans/opbeans-dotnet:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" - container_name: opbeans-dotnet - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} - - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} - - ELASTIC_APM_ENVIRONMENT=testing - - ELASTIC_APM_LOG_FILE=stderr - - ELASTIC_APM_LOG_LEVEL=debug - depends_on: - apm-server: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost"] - retries: 10 - interval: 20s - - opbeans-frontend: - build: . - image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" - container_name: opbeans-frontend - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} - depends_on: - opbeans-dotnet: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "exit 0"] - retries: 10 - interval: 20s - - apm-server: - image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} - ports: - - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" - - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" - command: > - apm-server -e - -E apm-server.frontend.enabled=true - -E apm-server.frontend.rate_limit=100000 - -E apm-server.host=0.0.0.0:8200 - -E apm-server.read_timeout=1m - -E apm-server.shutdown_timeout=2m - -E apm-server.write_timeout=1m - -E apm-server.rum.enabled=true - -E setup.template.settings.index.number_of_replicas=0 - -E xpack.monitoring.elasticsearch=true - -E cloud.id=${ELASTIC_CLOUD_ID} - -E cloud.auth=${ELASTIC_CLOUD_CREDENTIALS} - -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} - cap_drop: - - ALL - cap_add: - - CHOWN - - DAC_OVERRIDE - - SETGID - - SETUID - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] - retries: 10 - interval: 10s - - wait: - image: busybox - depends_on: - opbeans-frontend: - condition: service_healthy - -volumes: - esdata: - driver: local diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 0609ece..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: "2.1" -services: - opbeans-dotnet: - build: . - image: opbeans/opbeans-dotnet:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" - container_name: opbeans-dotnet - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} - - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} - - ELASTIC_APM_ENVIRONMENT=testing - - ELASTIC_APM_LOG_FILE=stderr - - ELASTIC_APM_LOG_LEVEL=debug - depends_on: - apm-server: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:80/ || exit 1"] - retries: 10 - interval: 20s - - opbeans-frontend: - build: . - image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" - container_name: opbeans-frontend - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} - depends_on: - opbeans-dotnet: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "exit 0"] - retries: 10 - interval: 20s - - apm-server: - image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} - ports: - - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" - - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" - command: > - apm-server -e - -E apm-server.frontend.enabled=true - -E apm-server.frontend.rate_limit=100000 - -E apm-server.host=0.0.0.0:8200 - -E apm-server.read_timeout=1m - -E apm-server.shutdown_timeout=2m - -E apm-server.write_timeout=1m - -E apm-server.rum.enabled=true - -E setup.kibana.host=kibana:5601 - -E setup.template.settings.index.number_of_replicas=0 - -E xpack.monitoring.elasticsearch=true - -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} - cap_drop: - - ALL - cap_add: - - CHOWN - - DAC_OVERRIDE - - SETGID - - SETUID - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - depends_on: - elasticsearch: - condition: service_healthy - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] - retries: 10 - interval: 10s - - elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION:-7.3.0} - environment: - - cluster.name=docker-cluster - - xpack.security.enabled=false - - bootstrap.memory_lock=true - - network.host=0.0.0.0 - - discovery.type=single-node - - "ES_JAVA_OPTS=-Xms1g -Xmx1g" - - "path.data=/usr/share/elasticsearch/data/${STACK_VERSION:-7.3.0}" - ulimits: - memlock: - soft: -1 - hard: -1 - mem_limit: 2g - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - ports: - - "127.0.0.1:${ELASTICSEARCH_PORT:-9200}:9200" - healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -vq '\"status\":\"red\"'"] - retries: 10 - interval: 20s - volumes: - - esdata:/usr/share/elasticsearch/data - - kibana: - image: docker.elastic.co/kibana/kibana:${STACK_VERSION:-7.3.0} - environment: - SERVER_NAME: kibana.example.org - ELASTICSEARCH_URL: http://elasticsearch:9200 - ports: - - "127.0.0.1:${KIBANA_PORT:-5601}:5601" - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://kibana:5601/"] - retries: 10 - interval: 10s - depends_on: - elasticsearch: - condition: service_healthy - - wait: - image: busybox - depends_on: - opbeans-frontend: - condition: service_healthy - -volumes: - esdata: - driver: local - From 42799eefb851c0490416fcba2a554bc03a417ff6 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 11 May 2022 17:11:57 +0200 Subject: [PATCH 3/6] Revert "Remove unused files" This reverts commit e0267f62c05a219da8d4a1f516fe63a67df9d444. --- Dockerfile | 23 +++++ Makefile | 36 ++++++++ docker-compose-elastic-cloud.yml | 95 ++++++++++++++++++++ docker-compose.yml | 147 +++++++++++++++++++++++++++++++ 4 files changed, 301 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose-elastic-cloud.yml create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d95ec91 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build +COPY . /src/ + +WORKDIR /src +RUN dotnet restore +RUN dotnet publish -c Release -o out + +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.7-alpine AS runtime +WORKDIR /app +COPY --from=build /src/out ./ +COPY --from=opbeans/opbeans-frontend:latest /app/build /opbeans-frontend + +LABEL \ + org.label-schema.schema-version="1.0" \ + org.label-schema.vendor="Elastic" \ + org.label-schema.name="opbeans-dotnet" \ + org.label-schema.version="1.11.1" \ + org.label-schema.url="https://hub.docker.com/r/opbeans/opbeans-dotnet" \ + org.label-schema.vcs-url="https://github.com/elastic/opbeans-dotnet" \ + org.label-schema.license="MIT" + +EXPOSE 80 +ENTRYPOINT ["dotnet", "opbeans-dotnet.dll"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b0b77f0 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +PORT ?= 80 +IMAGE ?= opbeans/opbeans-dotnet +VERSION ?= latest +LTS_ALPINE ?= 12-alpine + +.PHONY: help +.DEFAULT_GOAL := help + +help: ## Display this help text + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' + +all: build test + +build: ## Build docker image + @docker build --file Dockerfile --tag=${IMAGE}:${VERSION} . + +bats: ## Install bats in the project itself + @git clone https://github.com/sstephenson/bats.git + +prepare-test: bats ## Prepare the bats dependencies + @docker pull node:${LTS_ALPINE} + @mkdir -p target + @git submodule sync + @git submodule update --init --recursive + +test: prepare-test ## Run the tests + @bats/bin/bats --tap tests | tee target/results.tap + @docker run --rm -v "${PWD}":/usr/src/app -w /usr/src/app node:${LTS_ALPINE} \ + sh -c "npm install tap-xunit -g && cat target/results.tap | tap-xunit --package='co.elastic.opbeans' > target/junit-results.xml" + +publish: build ## Publish docker image + @docker push "${IMAGE}:${VERSION}" + +clean: ## Clean autogenerated files/folders + @rm -rf bats + @rm -rf target diff --git a/docker-compose-elastic-cloud.yml b/docker-compose-elastic-cloud.yml new file mode 100644 index 0000000..8886424 --- /dev/null +++ b/docker-compose-elastic-cloud.yml @@ -0,0 +1,95 @@ +version: "2.1" +services: + opbeans-dotnet: + build: . + image: opbeans/opbeans-dotnet:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" + container_name: opbeans-dotnet + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} + - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} + - ELASTIC_APM_ENVIRONMENT=testing + - ELASTIC_APM_LOG_FILE=stderr + - ELASTIC_APM_LOG_LEVEL=debug + depends_on: + apm-server: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -s http://localhost"] + retries: 10 + interval: 20s + + opbeans-frontend: + build: . + image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" + container_name: opbeans-frontend + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} + depends_on: + opbeans-dotnet: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "exit 0"] + retries: 10 + interval: 20s + + apm-server: + image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} + ports: + - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" + - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" + command: > + apm-server -e + -E apm-server.frontend.enabled=true + -E apm-server.frontend.rate_limit=100000 + -E apm-server.host=0.0.0.0:8200 + -E apm-server.read_timeout=1m + -E apm-server.shutdown_timeout=2m + -E apm-server.write_timeout=1m + -E apm-server.rum.enabled=true + -E setup.template.settings.index.number_of_replicas=0 + -E xpack.monitoring.elasticsearch=true + -E cloud.id=${ELASTIC_CLOUD_ID} + -E cloud.auth=${ELASTIC_CLOUD_CREDENTIALS} + -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} + cap_drop: + - ALL + cap_add: + - CHOWN + - DAC_OVERRIDE + - SETGID + - SETUID + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + healthcheck: + test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] + retries: 10 + interval: 10s + + wait: + image: busybox + depends_on: + opbeans-frontend: + condition: service_healthy + +volumes: + esdata: + driver: local diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0609ece --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,147 @@ +version: "2.1" +services: + opbeans-dotnet: + build: . + image: opbeans/opbeans-dotnet:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" + container_name: opbeans-dotnet + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} + - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} + - ELASTIC_APM_ENVIRONMENT=testing + - ELASTIC_APM_LOG_FILE=stderr + - ELASTIC_APM_LOG_LEVEL=debug + depends_on: + apm-server: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:80/ || exit 1"] + retries: 10 + interval: 20s + + opbeans-frontend: + build: . + image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" + container_name: opbeans-frontend + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} + depends_on: + opbeans-dotnet: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "exit 0"] + retries: 10 + interval: 20s + + apm-server: + image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} + ports: + - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" + - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" + command: > + apm-server -e + -E apm-server.frontend.enabled=true + -E apm-server.frontend.rate_limit=100000 + -E apm-server.host=0.0.0.0:8200 + -E apm-server.read_timeout=1m + -E apm-server.shutdown_timeout=2m + -E apm-server.write_timeout=1m + -E apm-server.rum.enabled=true + -E setup.kibana.host=kibana:5601 + -E setup.template.settings.index.number_of_replicas=0 + -E xpack.monitoring.elasticsearch=true + -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} + cap_drop: + - ALL + cap_add: + - CHOWN + - DAC_OVERRIDE + - SETGID + - SETUID + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + depends_on: + elasticsearch: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] + retries: 10 + interval: 10s + + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION:-7.3.0} + environment: + - cluster.name=docker-cluster + - xpack.security.enabled=false + - bootstrap.memory_lock=true + - network.host=0.0.0.0 + - discovery.type=single-node + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + - "path.data=/usr/share/elasticsearch/data/${STACK_VERSION:-7.3.0}" + ulimits: + memlock: + soft: -1 + hard: -1 + mem_limit: 2g + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + ports: + - "127.0.0.1:${ELASTICSEARCH_PORT:-9200}:9200" + healthcheck: + test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -vq '\"status\":\"red\"'"] + retries: 10 + interval: 20s + volumes: + - esdata:/usr/share/elasticsearch/data + + kibana: + image: docker.elastic.co/kibana/kibana:${STACK_VERSION:-7.3.0} + environment: + SERVER_NAME: kibana.example.org + ELASTICSEARCH_URL: http://elasticsearch:9200 + ports: + - "127.0.0.1:${KIBANA_PORT:-5601}:5601" + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + healthcheck: + test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://kibana:5601/"] + retries: 10 + interval: 10s + depends_on: + elasticsearch: + condition: service_healthy + + wait: + image: busybox + depends_on: + opbeans-frontend: + condition: service_healthy + +volumes: + esdata: + driver: local + From edd0941a64d8fe7841f2e4fc74ca0312d55d413b Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 11 May 2022 17:12:30 +0200 Subject: [PATCH 4/6] Remove unused files --- Dockerfile | 23 ----- docker-compose-elastic-cloud.yml | 95 -------------------- docker-compose.yml | 147 ------------------------------- 3 files changed, 265 deletions(-) delete mode 100644 Dockerfile delete mode 100644 docker-compose-elastic-cloud.yml delete mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d95ec91..0000000 --- a/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build -COPY . /src/ - -WORKDIR /src -RUN dotnet restore -RUN dotnet publish -c Release -o out - -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.7-alpine AS runtime -WORKDIR /app -COPY --from=build /src/out ./ -COPY --from=opbeans/opbeans-frontend:latest /app/build /opbeans-frontend - -LABEL \ - org.label-schema.schema-version="1.0" \ - org.label-schema.vendor="Elastic" \ - org.label-schema.name="opbeans-dotnet" \ - org.label-schema.version="1.11.1" \ - org.label-schema.url="https://hub.docker.com/r/opbeans/opbeans-dotnet" \ - org.label-schema.vcs-url="https://github.com/elastic/opbeans-dotnet" \ - org.label-schema.license="MIT" - -EXPOSE 80 -ENTRYPOINT ["dotnet", "opbeans-dotnet.dll"] diff --git a/docker-compose-elastic-cloud.yml b/docker-compose-elastic-cloud.yml deleted file mode 100644 index 8886424..0000000 --- a/docker-compose-elastic-cloud.yml +++ /dev/null @@ -1,95 +0,0 @@ -version: "2.1" -services: - opbeans-dotnet: - build: . - image: opbeans/opbeans-dotnet:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" - container_name: opbeans-dotnet - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} - - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} - - ELASTIC_APM_ENVIRONMENT=testing - - ELASTIC_APM_LOG_FILE=stderr - - ELASTIC_APM_LOG_LEVEL=debug - depends_on: - apm-server: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost"] - retries: 10 - interval: 20s - - opbeans-frontend: - build: . - image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" - container_name: opbeans-frontend - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} - depends_on: - opbeans-dotnet: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "exit 0"] - retries: 10 - interval: 20s - - apm-server: - image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} - ports: - - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" - - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" - command: > - apm-server -e - -E apm-server.frontend.enabled=true - -E apm-server.frontend.rate_limit=100000 - -E apm-server.host=0.0.0.0:8200 - -E apm-server.read_timeout=1m - -E apm-server.shutdown_timeout=2m - -E apm-server.write_timeout=1m - -E apm-server.rum.enabled=true - -E setup.template.settings.index.number_of_replicas=0 - -E xpack.monitoring.elasticsearch=true - -E cloud.id=${ELASTIC_CLOUD_ID} - -E cloud.auth=${ELASTIC_CLOUD_CREDENTIALS} - -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} - cap_drop: - - ALL - cap_add: - - CHOWN - - DAC_OVERRIDE - - SETGID - - SETUID - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] - retries: 10 - interval: 10s - - wait: - image: busybox - depends_on: - opbeans-frontend: - condition: service_healthy - -volumes: - esdata: - driver: local diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 0609ece..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: "2.1" -services: - opbeans-dotnet: - build: . - image: opbeans/opbeans-dotnet:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" - container_name: opbeans-dotnet - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} - - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} - - ELASTIC_APM_ENVIRONMENT=testing - - ELASTIC_APM_LOG_FILE=stderr - - ELASTIC_APM_LOG_LEVEL=debug - depends_on: - apm-server: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:80/ || exit 1"] - retries: 10 - interval: 20s - - opbeans-frontend: - build: . - image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" - container_name: opbeans-frontend - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} - depends_on: - opbeans-dotnet: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "exit 0"] - retries: 10 - interval: 20s - - apm-server: - image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} - ports: - - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" - - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" - command: > - apm-server -e - -E apm-server.frontend.enabled=true - -E apm-server.frontend.rate_limit=100000 - -E apm-server.host=0.0.0.0:8200 - -E apm-server.read_timeout=1m - -E apm-server.shutdown_timeout=2m - -E apm-server.write_timeout=1m - -E apm-server.rum.enabled=true - -E setup.kibana.host=kibana:5601 - -E setup.template.settings.index.number_of_replicas=0 - -E xpack.monitoring.elasticsearch=true - -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} - cap_drop: - - ALL - cap_add: - - CHOWN - - DAC_OVERRIDE - - SETGID - - SETUID - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - depends_on: - elasticsearch: - condition: service_healthy - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] - retries: 10 - interval: 10s - - elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION:-7.3.0} - environment: - - cluster.name=docker-cluster - - xpack.security.enabled=false - - bootstrap.memory_lock=true - - network.host=0.0.0.0 - - discovery.type=single-node - - "ES_JAVA_OPTS=-Xms1g -Xmx1g" - - "path.data=/usr/share/elasticsearch/data/${STACK_VERSION:-7.3.0}" - ulimits: - memlock: - soft: -1 - hard: -1 - mem_limit: 2g - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - ports: - - "127.0.0.1:${ELASTICSEARCH_PORT:-9200}:9200" - healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -vq '\"status\":\"red\"'"] - retries: 10 - interval: 20s - volumes: - - esdata:/usr/share/elasticsearch/data - - kibana: - image: docker.elastic.co/kibana/kibana:${STACK_VERSION:-7.3.0} - environment: - SERVER_NAME: kibana.example.org - ELASTICSEARCH_URL: http://elasticsearch:9200 - ports: - - "127.0.0.1:${KIBANA_PORT:-5601}:5601" - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://kibana:5601/"] - retries: 10 - interval: 10s - depends_on: - elasticsearch: - condition: service_healthy - - wait: - image: busybox - depends_on: - opbeans-frontend: - condition: service_healthy - -volumes: - esdata: - driver: local - From 23eb9f93099642c1d9cf2647fe99e61029858fd0 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 11 May 2022 17:21:46 +0200 Subject: [PATCH 5/6] Revert "Remove unused files" This reverts commit edd0941a64d8fe7841f2e4fc74ca0312d55d413b. --- Dockerfile | 23 +++++ docker-compose-elastic-cloud.yml | 95 ++++++++++++++++++++ docker-compose.yml | 147 +++++++++++++++++++++++++++++++ 3 files changed, 265 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose-elastic-cloud.yml create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d95ec91 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build +COPY . /src/ + +WORKDIR /src +RUN dotnet restore +RUN dotnet publish -c Release -o out + +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.7-alpine AS runtime +WORKDIR /app +COPY --from=build /src/out ./ +COPY --from=opbeans/opbeans-frontend:latest /app/build /opbeans-frontend + +LABEL \ + org.label-schema.schema-version="1.0" \ + org.label-schema.vendor="Elastic" \ + org.label-schema.name="opbeans-dotnet" \ + org.label-schema.version="1.11.1" \ + org.label-schema.url="https://hub.docker.com/r/opbeans/opbeans-dotnet" \ + org.label-schema.vcs-url="https://github.com/elastic/opbeans-dotnet" \ + org.label-schema.license="MIT" + +EXPOSE 80 +ENTRYPOINT ["dotnet", "opbeans-dotnet.dll"] diff --git a/docker-compose-elastic-cloud.yml b/docker-compose-elastic-cloud.yml new file mode 100644 index 0000000..8886424 --- /dev/null +++ b/docker-compose-elastic-cloud.yml @@ -0,0 +1,95 @@ +version: "2.1" +services: + opbeans-dotnet: + build: . + image: opbeans/opbeans-dotnet:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" + container_name: opbeans-dotnet + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} + - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} + - ELASTIC_APM_ENVIRONMENT=testing + - ELASTIC_APM_LOG_FILE=stderr + - ELASTIC_APM_LOG_LEVEL=debug + depends_on: + apm-server: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -s http://localhost"] + retries: 10 + interval: 20s + + opbeans-frontend: + build: . + image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" + container_name: opbeans-frontend + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} + depends_on: + opbeans-dotnet: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "exit 0"] + retries: 10 + interval: 20s + + apm-server: + image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} + ports: + - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" + - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" + command: > + apm-server -e + -E apm-server.frontend.enabled=true + -E apm-server.frontend.rate_limit=100000 + -E apm-server.host=0.0.0.0:8200 + -E apm-server.read_timeout=1m + -E apm-server.shutdown_timeout=2m + -E apm-server.write_timeout=1m + -E apm-server.rum.enabled=true + -E setup.template.settings.index.number_of_replicas=0 + -E xpack.monitoring.elasticsearch=true + -E cloud.id=${ELASTIC_CLOUD_ID} + -E cloud.auth=${ELASTIC_CLOUD_CREDENTIALS} + -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} + cap_drop: + - ALL + cap_add: + - CHOWN + - DAC_OVERRIDE + - SETGID + - SETUID + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + healthcheck: + test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] + retries: 10 + interval: 10s + + wait: + image: busybox + depends_on: + opbeans-frontend: + condition: service_healthy + +volumes: + esdata: + driver: local diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0609ece --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,147 @@ +version: "2.1" +services: + opbeans-dotnet: + build: . + image: opbeans/opbeans-dotnet:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" + container_name: opbeans-dotnet + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} + - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} + - ELASTIC_APM_ENVIRONMENT=testing + - ELASTIC_APM_LOG_FILE=stderr + - ELASTIC_APM_LOG_LEVEL=debug + depends_on: + apm-server: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:80/ || exit 1"] + retries: 10 + interval: 20s + + opbeans-frontend: + build: . + image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest + ports: + - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" + container_name: opbeans-frontend + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + environment: + - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} + - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} + depends_on: + opbeans-dotnet: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "exit 0"] + retries: 10 + interval: 20s + + apm-server: + image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} + ports: + - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" + - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" + command: > + apm-server -e + -E apm-server.frontend.enabled=true + -E apm-server.frontend.rate_limit=100000 + -E apm-server.host=0.0.0.0:8200 + -E apm-server.read_timeout=1m + -E apm-server.shutdown_timeout=2m + -E apm-server.write_timeout=1m + -E apm-server.rum.enabled=true + -E setup.kibana.host=kibana:5601 + -E setup.template.settings.index.number_of_replicas=0 + -E xpack.monitoring.elasticsearch=true + -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} + cap_drop: + - ALL + cap_add: + - CHOWN + - DAC_OVERRIDE + - SETGID + - SETUID + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + depends_on: + elasticsearch: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] + retries: 10 + interval: 10s + + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION:-7.3.0} + environment: + - cluster.name=docker-cluster + - xpack.security.enabled=false + - bootstrap.memory_lock=true + - network.host=0.0.0.0 + - discovery.type=single-node + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + - "path.data=/usr/share/elasticsearch/data/${STACK_VERSION:-7.3.0}" + ulimits: + memlock: + soft: -1 + hard: -1 + mem_limit: 2g + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + ports: + - "127.0.0.1:${ELASTICSEARCH_PORT:-9200}:9200" + healthcheck: + test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -vq '\"status\":\"red\"'"] + retries: 10 + interval: 20s + volumes: + - esdata:/usr/share/elasticsearch/data + + kibana: + image: docker.elastic.co/kibana/kibana:${STACK_VERSION:-7.3.0} + environment: + SERVER_NAME: kibana.example.org + ELASTICSEARCH_URL: http://elasticsearch:9200 + ports: + - "127.0.0.1:${KIBANA_PORT:-5601}:5601" + logging: + driver: 'json-file' + options: + max-size: '2m' + max-file: '5' + healthcheck: + test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://kibana:5601/"] + retries: 10 + interval: 10s + depends_on: + elasticsearch: + condition: service_healthy + + wait: + image: busybox + depends_on: + opbeans-frontend: + condition: service_healthy + +volumes: + esdata: + driver: local + From b0a1da9793adcaf0aedaf4af18ec1854ec899211 Mon Sep 17 00:00:00 2001 From: Greg Kalapos Date: Wed, 11 May 2022 17:25:49 +0200 Subject: [PATCH 6/6] Update dockerfile --- Dockerfile | 4 +- docker-compose-elastic-cloud.yml | 95 -------------------- docker-compose.yml | 147 ------------------------------- 3 files changed, 2 insertions(+), 244 deletions(-) delete mode 100644 docker-compose-elastic-cloud.yml delete mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index d95ec91..c3da22f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build COPY . /src/ WORKDIR /src RUN dotnet restore RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.7-alpine AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime WORKDIR /app COPY --from=build /src/out ./ COPY --from=opbeans/opbeans-frontend:latest /app/build /opbeans-frontend diff --git a/docker-compose-elastic-cloud.yml b/docker-compose-elastic-cloud.yml deleted file mode 100644 index 8886424..0000000 --- a/docker-compose-elastic-cloud.yml +++ /dev/null @@ -1,95 +0,0 @@ -version: "2.1" -services: - opbeans-dotnet: - build: . - image: opbeans/opbeans-dotnet:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" - container_name: opbeans-dotnet - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} - - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} - - ELASTIC_APM_ENVIRONMENT=testing - - ELASTIC_APM_LOG_FILE=stderr - - ELASTIC_APM_LOG_LEVEL=debug - depends_on: - apm-server: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost"] - retries: 10 - interval: 20s - - opbeans-frontend: - build: . - image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" - container_name: opbeans-frontend - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} - depends_on: - opbeans-dotnet: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "exit 0"] - retries: 10 - interval: 20s - - apm-server: - image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} - ports: - - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" - - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" - command: > - apm-server -e - -E apm-server.frontend.enabled=true - -E apm-server.frontend.rate_limit=100000 - -E apm-server.host=0.0.0.0:8200 - -E apm-server.read_timeout=1m - -E apm-server.shutdown_timeout=2m - -E apm-server.write_timeout=1m - -E apm-server.rum.enabled=true - -E setup.template.settings.index.number_of_replicas=0 - -E xpack.monitoring.elasticsearch=true - -E cloud.id=${ELASTIC_CLOUD_ID} - -E cloud.auth=${ELASTIC_CLOUD_CREDENTIALS} - -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} - cap_drop: - - ALL - cap_add: - - CHOWN - - DAC_OVERRIDE - - SETGID - - SETUID - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] - retries: 10 - interval: 10s - - wait: - image: busybox - depends_on: - opbeans-frontend: - condition: service_healthy - -volumes: - esdata: - driver: local diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 0609ece..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: "2.1" -services: - opbeans-dotnet: - build: . - image: opbeans/opbeans-dotnet:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-3000}:80" - container_name: opbeans-dotnet - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_APM_SERVICE_NAME=${ELASTIC_APM_SERVICE_NAME:-opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URL:-http://apm-server:8200} - - ELASTIC_APM_JS_SERVER_URL=${ELASTIC_APM_JS_SERVER_URL:-http://localhost:8200} - - ELASTIC_APM_ENVIRONMENT=testing - - ELASTIC_APM_LOG_FILE=stderr - - ELASTIC_APM_LOG_LEVEL=debug - depends_on: - apm-server: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:80/ || exit 1"] - retries: 10 - interval: 20s - - opbeans-frontend: - build: . - image: docker.elastic.co/observability-ci/it_opbeans-frontend_nginx:latest - ports: - - "127.0.0.1:${OPBEANS_DOTNET_PORT:-8000}:3000" - container_name: opbeans-frontend - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - environment: - - ELASTIC_OPBEANS_API_SERVER=${ELASTIC_OPBEANS_API_SERVER:-http://opbeans-dotnet} - - ELASTIC_APM_SERVER_URLS=${ELASTIC_APM_SERVER_URLS:-http://localhost:8200} - depends_on: - opbeans-dotnet: - condition: service_healthy - healthcheck: - test: ["CMD-SHELL", "exit 0"] - retries: 10 - interval: 20s - - apm-server: - image: docker.elastic.co/apm/apm-server:${STACK_VERSION:-7.3.0} - ports: - - "127.0.0.1:${APM_SERVER_PORT:-8200}:8200" - - "127.0.0.1:${APM_SERVER_MONITOR_PORT:-6060}:6060" - command: > - apm-server -e - -E apm-server.frontend.enabled=true - -E apm-server.frontend.rate_limit=100000 - -E apm-server.host=0.0.0.0:8200 - -E apm-server.read_timeout=1m - -E apm-server.shutdown_timeout=2m - -E apm-server.write_timeout=1m - -E apm-server.rum.enabled=true - -E setup.kibana.host=kibana:5601 - -E setup.template.settings.index.number_of_replicas=0 - -E xpack.monitoring.elasticsearch=true - -E output.elasticsearch.enabled=${APM_SERVER_ELASTICSEARCH_OUTPUT_ENABLED:-true} - cap_drop: - - ALL - cap_add: - - CHOWN - - DAC_OVERRIDE - - SETGID - - SETUID - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - depends_on: - elasticsearch: - condition: service_healthy - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://apm-server:8200/"] - retries: 10 - interval: 10s - - elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION:-7.3.0} - environment: - - cluster.name=docker-cluster - - xpack.security.enabled=false - - bootstrap.memory_lock=true - - network.host=0.0.0.0 - - discovery.type=single-node - - "ES_JAVA_OPTS=-Xms1g -Xmx1g" - - "path.data=/usr/share/elasticsearch/data/${STACK_VERSION:-7.3.0}" - ulimits: - memlock: - soft: -1 - hard: -1 - mem_limit: 2g - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - ports: - - "127.0.0.1:${ELASTICSEARCH_PORT:-9200}:9200" - healthcheck: - test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -vq '\"status\":\"red\"'"] - retries: 10 - interval: 20s - volumes: - - esdata:/usr/share/elasticsearch/data - - kibana: - image: docker.elastic.co/kibana/kibana:${STACK_VERSION:-7.3.0} - environment: - SERVER_NAME: kibana.example.org - ELASTICSEARCH_URL: http://elasticsearch:9200 - ports: - - "127.0.0.1:${KIBANA_PORT:-5601}:5601" - logging: - driver: 'json-file' - options: - max-size: '2m' - max-file: '5' - healthcheck: - test: ["CMD", "curl", "--write-out", "'HTTP %{http_code}'", "--silent", "--output", "/dev/null", "http://kibana:5601/"] - retries: 10 - interval: 10s - depends_on: - elasticsearch: - condition: service_healthy - - wait: - image: busybox - depends_on: - opbeans-frontend: - condition: service_healthy - -volumes: - esdata: - driver: local -