Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 9b79fb2

Browse files
committed
Add docker instructions to readme
1 parent 90cc8c6 commit 9b79fb2

File tree

8 files changed

+60
-10
lines changed

8 files changed

+60
-10
lines changed

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
**/.vs/
44
**/.vscode/
55
**/[Bb]in/
6-
**/[Oo]bj/
6+
**/[Oo]bj/
7+
**/*.sample.*
8+
tmp/
9+
**/.env
10+
**/*.md

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,4 +573,7 @@ FodyWeavers.xsd
573573
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,visualstudio,intellij+all,dotnetcore,windows,macos,linux
574574

575575
app-settings.*.json
576-
!app-settings.sample.json
576+
!app-settings.sample.json
577+
578+
# docker compose mounts
579+
tmp/

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ COPY --chown=mgc:mgc ./docker/* ./dist/
4646
RUN mkdir -p /app/.mgc /app/.local/share/.IdentityService /app/.local/share/keyrings &&\
4747
chmod +x /app/dist/init.sh
4848

49-
VOLUME [ "/app/.mgc", ".local/share/.IdentityService", "/app/.local/share/keyrings" ]
49+
VOLUME [ "/app/.mgc", "/app/.local/share/.IdentityService", "/app/.local/share/keyrings" ]
5050

5151
ENTRYPOINT ["./dist/init.sh"]
5252

docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@ services:
55
cap_add:
66
# https://man7.org/linux/man-pages/man7/capabilities.7.html
77
#
8-
- IPC_LOCK # Required by gnome-keyring daemon, the dbus secret service
8+
- IPC_LOCK # Required by gnome-keyring daemon, the dbus secret service
9+
environment:
10+
- KEYRING_PASSWORD=changeit
11+
volumes:
12+
- ./tmp/.mgc:/app/.mgc
13+
- ./tmp/.IdentityService:/app/.local/share/.IdentityService
14+
- ./tmp/keyrings:/app/.local/share/keyrings

docker/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Microsoft Graph CLI
2+
## Docker Image Help
3+
4+
### Quick start
5+
#### Running the container
6+
If you are using docker-compose:
7+
```sh
8+
$ docker-compose run -it mgc sh
9+
```
10+
11+
Otherwise use docker to run the container.
12+
```sh
13+
$ docker run -it --cap-add=IPC_LOCK --rm msgraph-cli sh
14+
```
15+
16+
> The IPC_LOCK capability is required by the `gnome-keyring-daemon` process which
17+
> performs token encryption.
18+
19+
#### Building an image
20+
Set the `NUGET_USER` and `NUGET_TOKEN` environment variables to a token that has pull package access to the [microsoft](https://github.com/microsoft) and [microsoftgraph](https://github.com/microsoftgraph) GitHub organizations.
21+
22+
To build an image in windows powershell:
23+
```powershell
24+
$ docker build \\?\$(Get-Location) -f . -t msgraph-cli --build-arg NUGET_USER=$env:NUGET_USER --build-arg NUGET_PASSWORD=$env:NUGET_TOKEN
25+
```
26+
27+
> The `\\?\$(Get-Location)` section of the command is used to get around the 260 character
28+
> limitation on windows systems that could cause issues when copying files to the docker
29+
> context. This issue impacts buildkit builds. For more information, check [this issue](https://github.com/moby/buildkit/issues/1366).
30+
31+
To build an image in linux or WSL:
32+
```sh
33+
$ docker build -t msgraph-cli --build-arg NUGET_USER=$NUGET_USER --build-arg NUGET_PASSWORD=$NUGET_TOKEN .
34+
```

docker/init.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env sh
22

3+
set -e
4+
35
script="$0"
46
DIR="$(dirname $script)"
57

@@ -10,4 +12,4 @@ else
1012
echo "dbus-daemon already running"
1113
fi
1214

13-
dbus-run-session -- echo "$KEYRING_PASSWORD" | gnome-keyring-daemon --daemonize --components=secrets --unlock && $@
15+
dbus-run-session -- echo "$KEYRING_PASSWORD" | gnome-keyring-daemon --daemonize --components=secrets --unlock && "$@"

src/app-settings.sample.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"AuthenticationOptions": {
33
"ClientId": "client id",
4-
"TenantId": "tenant id",
5-
"AllowUnencryptedTokenCache": false
4+
"TenantId": "tenant id"
65
},
76
"Logging": {
87
"LogLevel": {

src/msgraph-cli.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<Content Include="app-settings.json">
18-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19-
</Content>
17+
<None Update="app-settings.json" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" />
2018
</ItemGroup>
2119

20+
<PropertyGroup>
21+
<DefaultExcludesInProjectFolder>$(DefaultItemExcludes);**/*.sample.*</DefaultExcludesInProjectFolder>
22+
</PropertyGroup>
23+
2224
<ItemGroup>
2325
<PackageReference Include="Azure.Identity" Version="1.5.0" />
2426
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />

0 commit comments

Comments
 (0)