Skip to content

Commit

Permalink
Do not run as root when not needed. Remove WORKDIR in Dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Agustín Martínez Fayó <[email protected]>
  • Loading branch information
amartinezfayo committed Mar 18, 2024
1 parent 914cc93 commit 8cf4578
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \

FROM --platform=${BUILDPLATFORM} scratch AS spire-base
COPY --link --from=builder --chown=root:root --chmod=755 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
WORKDIR /opt/spire

# Preparation environment for setting up directories
FROM alpine as prep-spire-server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ docker-compose exec -T spire-server \
/opt/spire/bin/spire-server entry create \
-parentID "spiffe://domain.test/spire/agent/x509pop/$(fingerprint conf/agent/agent.crt.pem)" \
-spiffeID "spiffe://domain.test/authorized_delegate" \
-selector "unix:uid:1001" \
-selector "unix:uid:1000" \
-ttl 0
check-synced-entry "spire-agent" "spiffe://domain.test/authorized_delegate"

Expand Down
4 changes: 2 additions & 2 deletions test/integration/suites/delegatedidentity/05-test-endpoints
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

log-info "Test Delegated Identity API (for success)"
docker-compose exec -u 1001 -T spire-agent \
docker-compose exec -u 1001:1000 -T spire-agent \
/opt/spire/conf/agent/delegatedidentityclient -expectedID spiffe://domain.test/workload || fail-now "Failed to check Delegated Identity API"

log-info "Test Delegated Identity API (expecting permission denied)"
docker-compose exec -u 1002 -T spire-agent \
docker-compose exec -u 1002:1000 -T spire-agent \
/opt/spire/conf/agent/delegatedidentityclient || fail-now "Failed to check Delegated Identity API"
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ services:
volumes:
- ./conf/agent:/opt/spire/conf/agent
command: ["-config", "/opt/spire/conf/agent/agent.conf"]
user: 0:0
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- ./conf/agent:/opt/spire/conf/agent
- /var/run/docker.sock:/var/run/docker.sock
command: [ "-config", "/opt/spire/conf/agent/agent.conf" ]
user: 0:0
user: 0:0 # Required to access the Docker daemon socket
oidc-discovery-provider-server:
image: oidc-discovery-provider:latest-local
hostname: oidc-discovery-provider-server
Expand All @@ -25,7 +25,7 @@ services:
- ./conf/agent:/opt/spire/conf/agent
- ./conf/server:/opt/spire/conf/server
command: [ "-config", "/opt/spire/conf/oidc-discovery-provider/provider-server-api.conf" ]
user: 0:0
user: 0:0 # Required to access the Docker daemon socket
oidc-discovery-provider-workload:
pid: "host"
image: oidc-discovery-provider:latest-local
Expand All @@ -39,4 +39,4 @@ services:
- ./conf/agent:/opt/spire/conf/agent
- ./conf/server:/opt/spire/conf/server
command: [ "-config", "/opt/spire/conf/oidc-discovery-provider/provider-workload-api.conf" ]
user: 0:0
user: 0:0 # Required to access the Docker daemon socket

0 comments on commit 8cf4578

Please sign in to comment.