0

my docker file:

# syntax=docker/dockerfile:1

FROM golang:1.19-alpine AS build_con

COPY go.mod /
COPY go.sum /
COPY *.go /

RUN go mod download
RUN go get signservice
RUN go build -o /signservice_app /

FROM debian:bullseye-slim

RUN apt update && apt install -y \
pdftk \
imagemagick

RUN mkdir /signservice
RUN mkdir /signservice/resources
RUN mkdir /signservice/tmp

COPY --from=build_con signservice_app /signservice/signservice_app
COPY resources /signservice/resources/
COPY setperm.sh /signservice/
RUN chmod +x /signservice/setperm.sh
RUN chmod +x /signservice/signservice_app
RUN chmod 777 /signservice/
RUN chmod 777 /signservice/signservice_app
RUN /signservice/setperm.sh

ENTRYPOINT ["/signservice/signservice_app" ]

setperm.sh - is config for imagemagick

if entrypoint:

ENTRYPOINT ["/signservice/signservice_app" ]

output:

signservicetest  | exec /signservice/signservice_app: no such file or directory
signservicetest exited with code 0
signservicetest exited with code 1

if entrypoint:

ENTRYPOINT ["ls","-l", "/signservice/signservice_app" ]

output:

signservicetest  | -rwxrwxrwx 1 root root 11951301 Sep 27 12:15 /signservice/signservice_app

If i try set entrypoint after compile stage app is working

What is it?

Docker version 20.10.18, build b40c2f6 Ubuntu 20.04.5 LTS

  • `chmod 777` is almost always a significant security mistake: why do you want to allow an unprivileged user to be able to modify the code of the main container process? You probably don't need the `RUN chmod` or `RUN mkdir` commands at all. – David Maze Sep 27 '22 at 13:16
  • yes, it's not final container version in final version is `RUN chmod +x /signservice/setperm.sh` only usage, this test version – bdenisska Sep 27 '22 at 13:19
  • You either need to compile your go binary with static linking so there are no external libraries, or match the compile environment to the runtime environment. Alpine and Debian have different libc implementations (musl vs glibc). – BMitch Sep 27 '22 at 13:27
  • Try `RUN CGO_ENABLED=0 go build -o /signservice_app /` so the build does not depend on libraries based on your build env. As @Bmitch mentioned: running in different linux env's with differing `libc` implementations will most likely cause conflicts. – colm.anseo Sep 27 '22 at 13:34

0 Answers0