Skip to content

Commit fc23da9

Browse files
authored
Merge pull request #244 from nanotaboada/feature/compose
chore(container): rename Docker Compose file to preferred canonical form
2 parents 5df6384 + 5f54549 commit fc23da9

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

Dockerfile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS builder
77
WORKDIR /src
88

99
# Restore dependencies
10-
COPY src/Dotnet.Samples.AspNetCore.WebApi/*.csproj ./Dotnet.Samples.AspNetCore.WebApi/
10+
COPY src/Dotnet.Samples.AspNetCore.WebApi/*.csproj ./Dotnet.Samples.AspNetCore.WebApi/
1111
RUN dotnet restore ./Dotnet.Samples.AspNetCore.WebApi
1212

1313
# Copy source code and pre-seeded SQLite database
14-
COPY src/Dotnet.Samples.AspNetCore.WebApi ./Dotnet.Samples.AspNetCore.WebApi
14+
COPY src/Dotnet.Samples.AspNetCore.WebApi/ ./Dotnet.Samples.AspNetCore.WebApi/
1515

1616
WORKDIR /src/Dotnet.Samples.AspNetCore.WebApi
1717

@@ -41,26 +41,26 @@ ENV ASPNETCORE_URLS=http://+:9000
4141
ENV ASPNETCORE_ENVIRONMENT=Production
4242

4343
# Copy published app from builder
44-
COPY --from=builder /app/publish .
44+
COPY --from=builder /app/publish/ .
4545

4646
# Copy metadata docs for container registries (e.g.: GitHub Container Registry)
4747
COPY --chmod=444 README.md ./
48-
COPY --chmod=555 assets ./assets
48+
COPY --chmod=555 assets/ ./assets/
4949

5050
# https://rules.sonarsource.com/docker/RSPEC-6504/
5151

5252
# Copy entrypoint and healthcheck scripts
5353
COPY --chmod=555 scripts/entrypoint.sh ./entrypoint.sh
5454
COPY --chmod=555 scripts/healthcheck.sh ./healthcheck.sh
55+
# The 'hold' is our storage compartment within the image. Here, we copy a
56+
# pre-seeded SQLite database file, which Compose will mount as a persistent
57+
# 'storage' volume when the container starts up.
58+
COPY --from=builder /src/Dotnet.Samples.AspNetCore.WebApi/storage/players-sqlite3.db ./hold/players-sqlite3.db
5559

56-
57-
# Copy pre-seeded SQLite database as init bundle
58-
COPY --from=builder /src/Dotnet.Samples.AspNetCore.WebApi/storage/players-sqlite3.db ./docker-compose/players-sqlite3.db
59-
60-
# Create non-root user and make volume mount point writable
61-
RUN adduser --disabled-password --gecos '' aspnetcore && \
60+
# Add non-root user and make volume mount point writable
61+
RUN adduser --system --disabled-password --group aspnetcore && \
6262
mkdir -p /storage && \
63-
chown -R aspnetcore:aspnetcore /storage
63+
chown aspnetcore:aspnetcore /storage
6464

6565
USER aspnetcore
6666

docker-compose.yml renamed to compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ services:
1515

1616
volumes:
1717
storage:
18+
name: dotnet-samples-aspnetcore-webapi_storage

scripts/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
set -e
33

4-
IMAGE_STORAGE_PATH="/app/docker-compose/players-sqlite3.db"
4+
IMAGE_STORAGE_PATH="/app/hold/players-sqlite3.db"
55
VOLUME_STORAGE_PATH="/storage/players-sqlite3.db"
66

77
echo "✔ Starting container..."

scripts/healthcheck.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22
set -e
33

4-
# Simple health check using curl
5-
curl --fail http://localhost:9000/health
4+
# Minimal curl-based health check with timeout and error reporting
5+
curl --fail --silent --show-error --connect-timeout 1 --max-time 2 http://localhost:9000/health

src/Dotnet.Samples.AspNetCore.WebApi/Dotnet.Samples.AspNetCore.WebApi.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@
3939
<NoWarn>$(NoWarn);1591</NoWarn>
4040
</PropertyGroup>
4141

42+
<PropertyGroup>
43+
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
44+
</PropertyGroup>
45+
4246
</Project>

test/Dotnet.Samples.AspNetCore.WebApi.Tests/Dotnet.Samples.AspNetCore.WebApi.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@
2727
<ProjectReference Include="..\..\src\Dotnet.Samples.AspNetCore.WebApi\Dotnet.Samples.AspNetCore.WebApi.csproj" />
2828
</ItemGroup>
2929

30+
<PropertyGroup>
31+
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
32+
</PropertyGroup>
33+
3034
</Project>

0 commit comments

Comments
 (0)