Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image not built #8

Open
rschaaf-aifa opened this issue Oct 8, 2020 · 4 comments
Open

Docker image not built #8

rschaaf-aifa opened this issue Oct 8, 2020 · 4 comments

Comments

@rschaaf-aifa
Copy link

rschaaf-aifa commented Oct 8, 2020

docker build .

gives

Step 5/10 : RUN go get -d -v
 ---> Running in 982ca74350be
go: github.com/ccatp/antenna-control-unit/[email protected]: reading github.com/ccatp/antenna-control-unit/datasets/datasets/go.mod at revision datasets/v0.3.0: unknown revision datasets/v0.3.0
The command '/bin/sh -c go get -d -v' returned a non-zero code: 1

Changing Dockerfile to

FROM golang:1

# Work-around to access private repository:
# GITHUB_USER and GITHUB_PASS must be passed from docker command
# or from docker-compose.yml
ARG GITHUB_USER
ARG GITHUB_PASS
RUN echo "machine github.com\n\tlogin $GITHUB_USER\n\tpassword $GITHUB_PASS" >> ~/.netrc


WORKDIR /go/src/github.com/ccatp/telescope-control-system
COPY . .
RUN ./build-deps
RUN go get -d -v
RUN go test -v
RUN CGO_ENABLED=0 GOOS=linux go install -a -v

FROM scratch
COPY --from=0 /go/bin/telescope-control-system /
CMD ["/telescope-control-system"]

and building with

docker build --build-arg GITHUB_USER=$GITHUB_USER --build-arg GITHUB_PASS=$GITHUB_PASS .

with shell variables GITHUB_USER and GITHUB_PASS set, downlods everything from github:

Step 8/13 : RUN go get -d -v
 ---> Running in cf89a36640c2
go: downloading github.com/ccatp/antenna-control-unit/datasets v0.3.0
go: downloading github.com/pkg/errors v0.8.1

but still fails with

The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux go install -a -v' returned a non-zero code: 2

This Dockerfile

FROM golang:1

# Work-around to access private repository:
# GITHUB_USER and GITHUB_PASS must be passed from docker command
# or from docker-compose.yml
ARG GITHUB_USER
ARG GITHUB_PASS
RUN echo "machine github.com\n\tlogin $GITHUB_USER\n\tpassword $GITHUB_PASS" >> ~/.netrc

# Copy Source code...
WORKDIR /go/src/app
COPY . .

# Build and install TCS
RUN ./build-deps
RUN go install

CMD ["telescope-control-system"]

(slightly adapted from https://github.com/ccatp/demos/blob/master/2020-08-acu_sim-housekeeping/tcs/Dockerfile) works:

> docker build --build-arg GITHUB_USER=$GITHUB_USER --build-arg GITHUB_PASS=$GITHUB_PASS .
...
Successfully built d7e470da9eb0
> docker run d7e470da9eb0
2020/10/08 11:40:27 main.go:331: listening on :5600
2020/10/08 11:40:29 main.go:126: Get "http://172.16.5.95:8100/Values?identifier=DataSets.StatusGeneral8100&format=Binary": dial tcp 172.16.5.95:8100: i/o timeout (Client.Timeout exceeded while awaiting headers)
...
@nolta
Copy link
Member

nolta commented Oct 8, 2020

Fixed by 0b4c9cd and 3c4ef29.

@nolta nolta closed this as completed Oct 8, 2020
@rschaaf-aifa
Copy link
Author

rschaaf-aifa commented Oct 9, 2020

How do I use the image that is built by the github workflow? Most probably with

docker pull gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/telescope-control-system:latest

but what is secrets.GCLOUD_PROJECT_ID?

@rschaaf-aifa rschaaf-aifa reopened this Oct 9, 2020
@nolta
Copy link
Member

nolta commented Oct 15, 2020

I can also publish to github packages: https://github.com/ccatp/telescope-control-system/packages/447887

Does that work?

@rschaaf-aifa
Copy link
Author

Pulling the image from github works; building the image locally still fails with

Step 9/14 : RUN go get -d -v
 ---> Running in 34c1d13d9861
go: github.com/ccatp/antenna-control-unit/[email protected]: reading github.com/ccatp/antenna-control-unit/datasets/datasets/go.mod at revision datasets/v0.3.0: unknown revision datasets/v0.3.0
ERROR: Service 'tcs' failed to build: The command '/bin/sh -c go get -d -v' returned a non-zero code: 1

github_ssh_key_ed25519 contains my private key for github and was made accessible for docker, so I think that should work, but it doesn't... Anyway, I can make it work with

ARG GITHUB_USER
ARG GITHUB_PASS
RUN echo "machine github.com\n\tlogin $GITHUB_USER\n\tpassword $GITHUB_PASS" >> ~/.netrc

instead of

ADD github_ssh_key_ed25519 /root/.ssh/id_ed25519
RUN chmod 700 /root/.ssh/id_ed25519
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
RUN git config --global url.ssh://[email protected]/ccatp/.insteadOf https://github.com/ccatp/

in the Dockerfile, so I have a work-around, and since this is not my turf in the first place, we can leave it as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants