Skip to content

Commit a6f9291

Browse files
Use unprivileged user in Linux container (#27)
1 parent 8be5924 commit a6f9291

File tree

9 files changed

+47
-7
lines changed

9 files changed

+47
-7
lines changed

Test/Test.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void TestArchitecture(string lang, bool skipRestore)
5555
{
5656
var repository = "test.azurecr.io/test";
5757
var scaffoldName = BeforeEach(lang, repository, skipRestore);
58-
var filesToCheck = new List<string> { ".gitignore", "module.json", "Dockerfile", "Dockerfile.amd64.debug", "Dockerfile.arm32v7" };
58+
var filesToCheck = new List<string> { ".gitignore", "module.json", "Dockerfile.amd64", "Dockerfile.windows-amd64", "Dockerfile.amd64.debug", "Dockerfile.arm32v7" };
5959

6060
if (skipRestore)
6161
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM microsoft/dotnet:2.0-sdk AS build-env
2+
WORKDIR /app
3+
4+
COPY *.csproj ./
5+
RUN dotnet restore
6+
7+
COPY . ./
8+
RUN dotnet publish -c Release -o out
9+
10+
FROM microsoft/dotnet:2.0-runtime
11+
WORKDIR /app
12+
COPY --from=build-env /app/out ./
13+
14+
RUN useradd -ms /bin/bash moduleuser
15+
USER moduleuser
16+
17+
ENTRYPOINT ["dotnet", "SampleModule.dll"]

content/dotnet-template-azure-iot-edge-module/CSharp/Dockerfile.amd64.debug

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ FROM microsoft/dotnet:2.0-runtime-stretch AS base
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends unzip procps && \
5-
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg && \
65
rm -rf /var/lib/apt/lists/*
76

7+
RUN useradd -ms /bin/bash moduleuser
8+
USER moduleuser
9+
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
10+
811
FROM microsoft/dotnet:2.0-sdk AS build-env
912
WORKDIR /app
1013

File renamed without changes.

content/dotnet-template-azure-iot-edge-module/CSharp/module.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"tag": {
77
"version": "0.0.1",
88
"platforms": {
9-
"amd64": "./Dockerfile",
9+
"amd64": "./Dockerfile.amd64",
1010
"amd64.debug": "./Dockerfile.amd64.debug",
1111
"arm32v7": "./Dockerfile.arm32v7",
12-
"windows-amd64": "./Dockerfile"
12+
"windows-amd64": "./Dockerfile.windows-amd64"
1313
}
1414
},
1515
"buildOptions": []
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM microsoft/dotnet:2.0-sdk AS build-env
2+
WORKDIR /app
3+
4+
COPY *.fsproj ./
5+
RUN dotnet restore
6+
7+
COPY . ./
8+
RUN dotnet publish -c Release -o out
9+
10+
FROM microsoft/dotnet:2.0-runtime
11+
WORKDIR /app
12+
COPY --from=build-env /app/out ./
13+
14+
RUN useradd -ms /bin/bash moduleuser
15+
USER moduleuser
16+
17+
ENTRYPOINT ["dotnet", "SampleModule.dll"]

content/dotnet-template-azure-iot-edge-module/FSharp/Dockerfile.amd64.debug

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ FROM microsoft/dotnet:2.0-runtime-stretch AS base
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends unzip procps && \
5-
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg && \
65
rm -rf /var/lib/apt/lists/*
76

7+
RUN useradd -ms /bin/bash moduleuser
8+
USER moduleuser
9+
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
10+
811
FROM microsoft/dotnet:2.0-sdk AS build-env
912
WORKDIR /app
1013

File renamed without changes.

content/dotnet-template-azure-iot-edge-module/FSharp/module.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"tag": {
77
"version": "0.0.1",
88
"platforms": {
9-
"amd64": "./Dockerfile",
9+
"amd64": "./Dockerfile.amd64",
1010
"amd64.debug": "./Dockerfile.amd64.debug",
1111
"arm32v7": "./Dockerfile.arm32v7",
12-
"windows-amd64": "./Dockerfile"
12+
"windows-amd64": "./Dockerfile.windows-amd64"
1313
}
1414
},
1515
"buildOptions": []

0 commit comments

Comments
 (0)