Skip to content

Commit

Permalink
dockerfile, docker-compose.yml - builds and runs with agent enabled o…
Browse files Browse the repository at this point in the history
…n ubuntu, debian and alpine amd64
  • Loading branch information
tippmar-nr committed Jul 20, 2023
1 parent 0a23b4a commit 1e469a2
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 7 deletions.
6 changes: 6 additions & 0 deletions tests/Agent/IntegrationTests/ContainerApplications/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AGENT_PATH=../../../../src/Agent/newrelichome_x64_coreclr_linux
LOG_PATH=./logs

NEW_RELIC_LICENSE_KEY=78dc6026a9304e2e244e943555f0add873427d1d
NEW_RELIC_HOST=staging-collector.newrelic.com
NEW_RELIC_APP_NAME=SmokeTestApp
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000"
ARG DISTRO_TAG
FROM mcr.microsoft.com/dotnet/aspnet:${DISTRO_TAG} AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000"
FROM mcr.microsoft.com/dotnet/sdk:${DISTRO_TAG} AS build
WORKDIR /src
COPY ["ContainerApplications/SmokeTestApp/SmokeTestApp.csproj", "SmokeTestApp/"]
COPY ["SmokeTestApp/SmokeTestApp.csproj", "SmokeTestApp/"]
RUN dotnet restore "SmokeTestApp/SmokeTestApp.csproj"
COPY . .
WORKDIR "/src/SmokeTestApp"
RUN dotnet build "SmokeTestApp.csproj" -c Release -o /app/build

FROM build AS publish
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000"
RUN dotnet publish "SmokeTestApp.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000"

# Enable the agent
ARG NEW_RELIC_HOST
ARG NEW_RELIC_LICENSE_KEY
ARG NEW_RELIC_APP_NAME

ENV CORECLR_ENABLE_PROFILING=1 \
CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A} \
CORECLR_NEWRELIC_HOME=/usr/local/newrelic-dotnet-agent \
CORECLR_PROFILER_PATH=/usr/local/newrelic-dotnet-agent/libNewRelicProfiler.so \
NEW_RELIC_HOST=${NEW_RELIC_HOST} \
NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY} \
NEW_RELIC_APP_NAME=${NEW_RELIC_APP_NAME} \
NEWRELIC_LOG_DIRECTORY=/app/logs

WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "SmokeTestApp.dll"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "3"

services:
smoketestapp-debian:
build:
context: .
dockerfile: SmokeTestApp/Dockerfile
args:
DISTRO_TAG: 7.0-bullseye-slim-amd64
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_HOST: ${NEW_RELIC_HOST}

ports:
- "8001:80"
volumes:
- ${AGENT_PATH}:/usr/local/newrelic-dotnet-agent # AGENT_PATH from .env, points to newrelichome_linux_x64
- ${LOG_PATH}:/app/logs # LOG_PATH from .env, should be a folder unique to this run of the smoketest app

smoketestapp-alpine:
build:
context: .
dockerfile: SmokeTestApp/Dockerfile
args:
DISTRO_TAG: 7.0-alpine-amd64
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_HOST: ${NEW_RELIC_HOST}
ports:
- "8002:80"
volumes:
- ${AGENT_PATH}:/usr/local/newrelic-dotnet-agent # AGENT_PATH from .env, points to newrelichome_linux_x64
- ${LOG_PATH}:/app/logs # LOG_PATH from .env, should be a folder unique to this run of the smoketest app

smoketestapp-ubuntu:
build:
context: .
dockerfile: SmokeTestApp/Dockerfile
args:
DISTRO_TAG: 7.0-jammy-amd64
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_HOST: ${NEW_RELIC_HOST}
ports:
- "8003:80"
volumes:
- ${AGENT_PATH}:/usr/local/newrelic-dotnet-agent # AGENT_PATH from .env, points to newrelichome_linux_x64
- ${LOG_PATH}:/app/logs # LOG_PATH from .env, should be a folder unique to this run of the smoketest app


13 changes: 13 additions & 0 deletions tests/Agent/IntegrationTests/ContainerIntegrationTests.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmokeTestApp", "ContainerAp
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ContainerApplications", "ContainerApplications", "{84D70574-4AC7-4EA7-AE52-832C3531E082}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewRelic.Api.Agent", "..\..\..\src\Agent\NewRelic.Api.Agent\NewRelic.Api.Agent.csproj", "{F7EFC853-3F97-4D91-9A6F-37ADAAC739C1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_docker", "_docker", "{FB10922F-3CC6-4497-AF53-DF6808380258}"
ProjectSection(SolutionItems) = preProject
ContainerApplications\.env = ContainerApplications\.env
ContainerApplications\docker-compose.yml = ContainerApplications\docker-compose.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -41,12 +49,17 @@ Global
{FBA07795-8066-4641-88E5-05DD272D333A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBA07795-8066-4641-88E5-05DD272D333A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBA07795-8066-4641-88E5-05DD272D333A}.Release|Any CPU.Build.0 = Release|Any CPU
{F7EFC853-3F97-4D91-9A6F-37ADAAC739C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7EFC853-3F97-4D91-9A6F-37ADAAC739C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7EFC853-3F97-4D91-9A6F-37ADAAC739C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7EFC853-3F97-4D91-9A6F-37ADAAC739C1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FBA07795-8066-4641-88E5-05DD272D333A} = {84D70574-4AC7-4EA7-AE52-832C3531E082}
{FB10922F-3CC6-4497-AF53-DF6808380258} = {84D70574-4AC7-4EA7-AE52-832C3531E082}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB230433-D05D-4A1F-951B-CC14F47BBF42}
Expand Down

0 comments on commit 1e469a2

Please sign in to comment.