Skip to content

Commit

Permalink
fix(oci): copy custom /etc/passwd file
Browse files Browse the repository at this point in the history
* copy from host
* new username: scratch-user
* includes scratch-user because docker cannot create users in scratch
* source: https://stackoverflow.com/a/67703976 a. https://medium.com/@lizrice/non-privileged-containers-based-on-the-scratch-image-a80105d6d341

Signed-off-by: Frederik Zorn <federdaemn@mail.de>
  • Loading branch information
z0rrn committed Nov 15, 2023
1 parent d23eeb1 commit 1ad45f2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ License: Apache-2.0
Files: anki-sync-server/imgs/ah-logo.png
Copyright: Alex Fraser https://apps.ankiweb.net/
License: LicenseRef-anki-logo

# this file contains the user used in the container (see https://github.com/federdaemn/docker-anki-sync-server/issues/2)
Files: tools/minimal-passwd.txt
Copyright: 2023 Frederik Zorn <federdaemn@mail.de>
License: Apache-2.0
4 changes: 2 additions & 2 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ version: "3.7"
services:

anki-sync-server:
# https://github.com/federdaemn/anki-sync-server/blob/main/SETUP.md
image: ghcr.io/federdaemn/anki-sync-server:2.1.66
# https://github.com/federdaemn/docker-anki-sync-server/blob/main/SETUP.md
image: ghcr.io/federdaemn/anki-sync-server:23.10.1
container_name: anki-sync-server
restart: unless-stopped
# these are sample passwords, please change them
Expand Down
5 changes: 4 additions & 1 deletion anki-sync-server/containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ RUN \
# copy binary container with nothing other to reduce container size
FROM scratch

# copy /etc/passwd because docker cannot create one in a scratch container
COPY tools/minimal-passwd.txt /etc/passwd

# copy binary from builder
COPY --from=builder /output/anki-sync-server /app/anki-sync-server

Expand All @@ -65,7 +68,7 @@ ENV \
SYNC_PORT="27701"

# switch user for better security
USER anki-sync-server
USER scratch-user

# don't forget to set at least SYNC_USER1
CMD [ "/app/anki-sync-server" ]
Expand Down
2 changes: 1 addition & 1 deletion tools/convert-arch-cargo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ case $TARGET in

"amd64")
echo "x86_64-unknown-linux-gnu" > /.cargo-platform.txt
echo "NOTHING=unimportant" > /.cargo-linker.txt
echo "NOTHING=nothing" > /.cargo-linker.txt
echo "gcc g++" > /.c-compiler.txt
;;
"arm64")
Expand Down
1 change: 1 addition & 0 deletions tools/minimal-passwd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scratch-user:*:65534:65534:scratch-user:/nonexistent:/sbin/nologin

0 comments on commit 1ad45f2

Please sign in to comment.