Skip to content

Commit 9ab1fad

Browse files
dabatesdanielunderwood
authored andcommitted
Changes for Docker (Radarr#4)
* Changes for Docker - Added code to check for EnvironmentVariables and use them if they exist - Updates DockerFile for more effiency (if using the sdk, don't need to import the runtime as it comes with the sdk) - Updates the DockerCompose file with new Env Variables * Cleanup - Removes missed debug code
1 parent 2ef7aac commit 9ab1fad

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM microsoft/dotnet:2.0-sdk AS build-env
1+
FROM microsoft/dotnet:2.0-sdk
22
WORKDIR /app
33

44
# copy csproj and restore as distinct layers
@@ -9,8 +9,4 @@ RUN dotnet restore
99
COPY LidarrAPI/* ./
1010
RUN dotnet publish -c Release -o out
1111

12-
# build runtime image
13-
FROM microsoft/dotnet:2.0-runtime
14-
WORKDIR /app
15-
COPY --from=build-env /app/out ./
16-
ENTRYPOINT ["dotnet", "LidarrAPI.dll"]
12+
ENTRYPOINT ["dotnet", "out/LidarrAPI.dll"]

LidarrAPI/Startup.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ public Startup(IConfiguration configuration, IHostingEnvironment env)
2626
ConfigLidarr = Config.GetSection("Lidarr").Get<Config>();
2727

2828
env.ConfigureNLog("nlog.config");
29-
29+
30+
// If env variables exist, read those in instead
31+
ConfigLidarr.Database = Environment.GetEnvironmentVariable("Database") ?? ConfigLidarr.Database;
32+
ConfigLidarr.DataDirectory = Environment.GetEnvironmentVariable("DataDirectory") ?? ConfigLidarr.DataDirectory;
33+
ConfigLidarr.ApiKey = Environment.GetEnvironmentVariable("ApiKey") ?? ConfigLidarr.ApiKey;
34+
ConfigLidarr.AppVeyorApiKey = Environment.GetEnvironmentVariable("AppVeyorApiKey") ?? ConfigLidarr.AppVeyorApiKey;
35+
3036
SetupDataDirectory();
3137
SetupDatadog();
3238
}
@@ -72,7 +78,7 @@ private void SetupDataDirectory()
7278
// Check data path
7379
if (!Path.IsPathRooted(ConfigLidarr.DataDirectory))
7480
{
75-
throw new Exception("DataDirectory path must be absolute.");
81+
throw new Exception($"DataDirectory path must be absolute.\nDataDirectory: {ConfigLidarr.DataDirectory}");
7682
}
7783

7884
// Create

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ services:
1818
environment:
1919
- DataDirectory=/data
2020
- Database="server=127.0.0.1;user id=root;password=${MYSQL_ROOT_PASSWORD};database=lidarrupdate;CharSet=utf8mb4"
21+
- ApiKey=
22+
- ASPNETCORE_URLS=http://0.0.0.0:5000
2123

2224
volumes:
2325
- ./lidarrupdate-data:/data

0 commit comments

Comments
 (0)