Go and binaries were part of our docker image.
I tried all possible combinations to build Go binary
export GOARCH=386 && export GOOS=linux && go build ./cmd/status
export GOARCH=amd64 && export GOOS=windows && go build ./cmd/status
$ uname -a
Linux runner-4KP_No95-project-35871-concurrent-0 44.44.444-115.233.amzn1.x86_64 #1 SMP Thu Feb 27 23:49:15 UTC 2020 x86_64 GNU/Linux
Getting error as
/pipeline/status: /pipeline/status: cannot execute binary file
Sample section from docker file is -
ARG GOLANG_VERSION=1.14
FROM golang:${GOLANG_VERSION} as build-helpers
ENV GOPRIVATE=code.abcd.com
RUN mkdir -p /pipeline-helpers
ADD /reusable-aspects/ci-caching/golang-preheat-cache /golang-preheat-cache
RUN cd /golang-preheat-cache && go mod download
ADD helpers/go-pipeline-commands /pipeline-helpers/
RUN cd /pipeline-helpers && CGO_ENABLED=0 GOOS=linux make
FROM alpine
RUN mkdir -p /pipeline
WORKDIR /pipeline
COPY --from=build-helpers /pipeline-helpers/commit .
COPY --from=build-helpers /pipeline-helpers/status .
RUN chmod a+x commit
RUN chmod a+x status
ENTRYPOINT ["./commit"]
CMD []
Image logs where Go binaries are build are added below
[0KRunning with gitlab-runner 11.11.2 (ac2a293c)
[0;m[0K on aws-build-runner-scheduler 8616255e
[0;msection_start:1590231123:prepare_executor
[0K[0KUsing Docker executor with image gcr.io/kaniko-project/executor:debug ...
[0;m[0KPulling docker image gcr.io/kaniko-project/executor:debug ...
[0;m[0KUsing docker image sha256:adasdasdasdasdasdasdasdsa for gcr.io/kaniko-project/executor:debug ...
[0;msection_end:1590231124:prepare_executor
[0Ksection_start:1590231124:prepare_script
[0KRunning on runner-8616123e-project-12312-concurrent-0 via ip-12-122-122-122...
section_end:1590231125:prepare_script
[0Ksection_start:1590231125:get_sources
[0KReinitialized existing Git repository in /builds/abcde/pipeline/projetname/.git/
[32;1mFetching changes...[0;m
From https://code.abc.com/abcde/pipeline/projetname
* [new ref] refs/pipelines/5679048 -> refs/pipelines/5679048
0286714..043832e feat/qaPipelineDeploy -> origin/feat/qaPipelineDeploy
[32;1mChecking out 043832ea as feat/qaPipelineDeploy...[0;m
Removing helpers/bash-commons/src/welcome/version-info-pipeline.txt
[32;1mSkipping Git submodules setup[0;m
section_end:1590231128:get_sources
[0Ksection_start:1590231128:restore_cache
[0Ksection_end:1590231130:restore_cache
[0Ksection_start:1590231130:download_artifacts
[0Ksection_end:1590231132:download_artifacts
[0Ksection_start:1590231132:build_script
[0K[32;1m$ mkdir -p /kaniko/.docker[0;m
[32;1m$ export IMAGE_TAG=${CI_COMMIT_TAG:=$CI_COMMIT_REF_SLUG}[0;m
[32;1m$ imagename=$CI_REGISTRY_IMAGE/helpers:$IMAGE_TAG[0;m
[36mINFO[0m[0001] Resolved base name golang:1.14 to build-helpers
[36mINFO[0m[0001] Retrieving image manifest golang:1.14
[36mINFO[0m[0002] Retrieving image manifest golang:1.14
[36mINFO[0m[0003] Retrieving image manifest alpine
[36mINFO[0m[0004] Retrieving image manifest alpine
[36mINFO[0m[0005] Built cross stage deps: map[0:[/pipeline-helpers/commit /pipeline-helpers/status]]
[36mINFO[0m[0005] Retrieving image manifest golang:1.14
[36mINFO[0m[0005] Retrieving image manifest golang:1.14
[36mINFO[0m[0006] Executing 0 build triggers
[36mINFO[0m[0006] Unpacking rootfs as cmd RUN mkdir -p /pipeline-helpers requires it.
[36mINFO[0m[0021] ENV GOPRIVATE=code.abc.com
[36mINFO[0m[0021] RUN mkdir -p /pipeline-helpers
[36mINFO[0m[0021] Taking snapshot of full filesystem...
[36mINFO[0m[0022] Resolving 28120 paths
[36mINFO[0m[0025] cmd: /bin/sh
[36mINFO[0m[0025] args: [-c mkdir -p /pipeline-helpers]
[36mINFO[0m[0025] Running: [/bin/sh -c mkdir -p /pipeline-helpers]
[36mINFO[0m[0025] Taking snapshot of full filesystem...
[36mINFO[0m[0025] Resolving 28121 paths
[36mINFO[0m[0027] Using files from context: [/builds/abcde/pipeline/projetname/projetname-reusable-aspects/ci-caching/golang-preheat-cache]
[36mINFO[0m[0027] ADD /projetname-reusable-aspects/ci-caching/golang-preheat-cache /golang-preheat-cache
[36mINFO[0m[0027] Resolving 3 paths
[36mINFO[0m[0027] Taking snapshot of files...
[36mINFO[0m[0027] RUN cd /golang-preheat-cache && go mod download
[36mINFO[0m[0027] cmd: /bin/sh
[36mINFO[0m[0027] args: [-c cd /golang-preheat-cache && go mod download]
[36mINFO[0m[0027] Running: [/bin/sh -c cd /golang-preheat-cache && go mod download]
[36mINFO[0m[0033] Taking snapshot of full filesystem...
[36mINFO[0m[0033] Resolving 50967 paths
[36mINFO[0m[0045] Using files from context: [/builds/abcde/pipeline/projetname/helpers/go-pipeline-commands]
[36mINFO[0m[0045] ADD helpers/go-pipeline-commands /pipeline-helpers/
[36mINFO[0m[0045] Resolving 25 paths
[36mINFO[0m[0045] Taking snapshot of files...
[36mINFO[0m[0045] RUN cd /pipeline-helpers && CGO_ENABLED=0 GOOS=linux make
[36mINFO[0m[0045] cmd: /bin/sh
[36mINFO[0m[0045] args: [-c cd /pipeline-helpers && CGO_ENABLED=0 GOOS=linux make]
[36mINFO[0m[0045] Running: [/bin/sh -c cd /pipeline-helpers && CGO_ENABLED=0 GOOS=linux make]
[34m > Download dependencies [0m
[37m > Tidy dependencies [0m
[34m go mod tidy [0m
[37m > Building the binary [0m
[34m go build ./cmd/commit [0m
[34m go build ./cmd/query-qa-pipeline-status [0m
[37m > Format code [0m
[34m go fmt ./... [0m
[37m > Run unit tests [0m
[34m go test -run TestUnit ./... [0m
ok code.abc.com/abcde/pipeline/projetname/helpers/cmd/commit 0.005s
ok code.abc.com/abcde/pipeline/projetname/helpers/cmd/status 0.005s
[37m > Find static code issues [0m
[34m go vet ./... [0m
[36mINFO[0m[0055] Taking snapshot of full filesystem...
[36mINFO[0m[0056] Resolving 52425 paths
[36mINFO[0m[0061] RUN echo " Golang version: `go version`" >> /pipeline-helpers/version-info-pipeline.txt
[36mINFO[0m[0061] cmd: /bin/sh
[36mINFO[0m[0061] args: [-c echo " Golang version: `go version`" >> /pipeline-helpers/version-info-pipeline.txt]
[36mINFO[0m[0061] Running: [/bin/sh -c echo " Golang version: `go version`" >> /pipeline-helpers/version-info-pipeline.txt]
[36mINFO[0m[0061] Taking snapshot of full filesystem...
[36mINFO[0m[0065] Resolving 52426 paths
[36mINFO[0m[0069] RUN echo " projetname type: Helpers" >> /pipeline-helpers/version-info-pipeline.txt
[36mINFO[0m[0069] cmd: /bin/sh
[36mINFO[0m[0069] args: [-c echo " projetname type: Helpers" >> /pipeline-helpers/version-info-pipeline.txt]
[36mINFO[0m[0069] Running: [/bin/sh -c echo " projetname type: Helpers" >> /pipeline-helpers/version-info-pipeline.txt]
[36mINFO[0m[0069] Taking snapshot of full filesystem...
[36mINFO[0m[0069] Resolving 52426 paths
[36mINFO[0m[0072] RUN echo " Commit hash: `echo ${CI_COMMIT_SHA}`" >> /pipeline-helpers/version-info-pipeline.txt
[36mINFO[0m[0072] cmd: /bin/sh
[36mINFO[0m[0072] args: [-c echo " Commit hash: `echo ${CI_COMMIT_SHA}`" >> /pipeline-helpers/version-info-pipeline.txt]
[36mINFO[0m[0072] Running: [/bin/sh -c echo " Commit hash: `echo ${CI_COMMIT_SHA}`" >> /pipeline-helpers/version-info-pipeline.txt]
[36mINFO[0m[0072] Taking snapshot of full filesystem...
[36mINFO[0m[0072] Resolving 52426 paths
[36mINFO[0m[0076] Saving file pipeline-helpers/commit for later use
[36mINFO[0m[0076] Saving file pipeline-helpers/version-info-pipeline.txt for later use
[36mINFO[0m[0076] Saving file pipeline-helpers/status for later use
[36mINFO[0m[0076] Deleting filesystem...
[36mINFO[0m[0077] Retrieving image manifest alpine
[36mINFO[0m[0079] Retrieving image manifest alpine
[36mINFO[0m[0080] Executing 0 build triggers
[36mINFO[0m[0080] Unpacking rootfs as cmd RUN mkdir -p /pipeline requires it.
[36mINFO[0m[0080] RUN mkdir -p /pipeline
[36mINFO[0m[0080] Taking snapshot of full filesystem...
[36mINFO[0m[0080] Resolving 482 paths
[36mINFO[0m[0080] cmd: /bin/sh
[36mINFO[0m[0080] args: [-c mkdir -p /pipeline]
[36mINFO[0m[0080] Running: [/bin/sh -c mkdir -p /pipeline]
[36mINFO[0m[0080] Taking snapshot of full filesystem...
[36mINFO[0m[0080] Resolving 483 paths
[36mINFO[0m[0080] WORKDIR /pipeline
[36mINFO[0m[0080] cmd: workdir
[36mINFO[0m[0080] Changed working directory to /pipeline
[36mINFO[0m[0080] COPY --from=build-helpers /pipeline-helpers/commit .
[36mINFO[0m[0080] Resolving 1 paths
[36mINFO[0m[0080] Taking snapshot of files...
[36mINFO[0m[0080] Resolving 1 paths
[36mINFO[0m[0080] Taking snapshot of files...
[36mINFO[0m[0081] Resolving 1 paths
[36mINFO[0m[0081] Taking snapshot of files...
[36mINFO[0m[0081] COPY --from=build-helpers /pipeline-helpers/status .
[36mINFO[0m[0081] Resolving 1 paths
[36mINFO[0m[0081] Taking snapshot of files...
[36mINFO[0m[0081] RUN chmod a+x commit
[36mINFO[0m[0081] cmd: /bin/sh
[36mINFO[0m[0081] args: [-c chmod a+x commit]
[36mINFO[0m[0081] Running: [/bin/sh -c chmod a+x commit]
[36mINFO[0m[0081] Taking snapshot of full filesystem...
[36mINFO[0m[0081] Resolving 487 paths
[36mINFO[0m[0081] No files were changed, appending empty layer to config. No layer added to image.
[36mINFO[0m[0081] cmd: /bin/sh
[36mINFO[0m[0081] Taking snapshot of full filesystem...
[36mINFO[0m[0081] Resolving 487 paths
[36mINFO[0m[0081] No files were changed, appending empty layer to config. No layer added to image.
[36mINFO[0m[0081] RUN chmod a+x status
[36mINFO[0m[0081] cmd: /bin/sh
[36mINFO[0m[0081] args: [-c chmod a+x status]
[36mINFO[0m[0081] Running: [/bin/sh -c chmod a+x status]
[36mINFO[0m[0081] Taking snapshot of full filesystem...
[36mINFO[0m[0081] Resolving 487 paths
[36mINFO[0m[0081] No files were changed, appending empty layer to config. No layer added to image.
[36mINFO[0m[0081] CMD []
[32;1m$ echo projetname_IMAGE_TAG=${IMAGE_TAG}[0;m
projetname_IMAGE_TAG=feat-qapipelinedeploy
section_end:1590231218:build_script
[0Ksection_start:1590231218:after_script
[0Ksection_end:1590231219:after_script
[0Ksection_start:1590231219:archive_cache
[0Ksection_end:1590231220:archive_cache
[0Ksection_start:1590231220:upload_artifacts_on_success
[0Ksection_end:1590231222:upload_artifacts_on_success
[0K[32;1mJob succeeded
From Docker GIT.YML file , I am calling bash ./status command. It throws error as can not execute bianry file
There is one more docker file that gets build in a different stage after above docker image gets build. This docker image is used for testing in YML file.
RG GO_VERSION=1.14
# Install OpenAPI Validator
FROM golang:${GO_VERSION} AS openapivalidatorbuilder
WORKDIR /work
ENV GOPRIVATE=code.abcd.com
COPY /reusable-aspects/enforcement/open-api-check/ .
RUN go build .
ARG PIPELINE_HELPER=docker.abcd.com/projectName/pipeline/projects/helpers:master
FROM ${PIPELINE_HELPER} as helper
FROM golang:${GO_VERSION}
ENV GOPRIVATE=code.abcd.com
ADD /reusable-aspects/ci-caching/golang-preheat-cache /golang-preheat-cache
RUN cd /golang-preheat-cache && go mod download
RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.1.0/envsubst-`uname -s`-`uname -m` -o envsubst
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
nodejs \
npm \
unzip
RUN npm --version
RUN npm install -g \
npm#6.11 \
serverless#1.51
RUN apt-get install -y \
# Install ruby and CFN_NAG
ruby-dev \
ruby-json \
ruby \
ruby-bundler \
# Install AWS CLI
awscli \
jq \
figlet
RUN rm -rf /var/cache/apk/*
RUN gem install cfn-nag --no-rdoc --no-ri
RUN mkdir /pipeline
ADD helpers/bash-commons/src/welcome /pipeline
RUN echo " Golang version: `go version`" >> /pipeline/version-info-pipeline.txt
RUN echo " Node version: `node -v`" >> /pipeline/version-info-pipeline.txt
RUN echo " Serverless version: `serverless -v`" >> /pipeline/version-info-pipeline.txt
RUN echo " projects type: Information Serverless Golang" >> /pipeline/version-info-pipeline.txt
COPY --from=openapivalidatorbuilder /work/open-api-check /pipeline/open-api-check
RUN chmod a+x /pipeline/open-api-check
COPY --from=helper /pipeline/hash /pipeline
COPY --from=helper /pipeline/status /pipeline
golang:1.14 is not alpine base but debian base. So of course you cannot run the debian build binary in alpine image.
Try replace
FROM golang:${GOLANG_VERSION} as build-helpers
with
FROM golang:${GOLANG_VERSION}-alpine as build-helpers
and add following lines to download necessary lib for building binary
RUN apk update && \
apk --update upgrade && \
apk add --no-cache ca-certificates gcc musl-dev git && \
update-ca-certificates && \
rm -rf /var/cache/apk/*
UPDATE
Add make and put the apk update and add right under FROM golang:...
FROM golang:${GOLANG_VERSION}-alpine as build-helpers
RUN apk update && \
apk --update upgrade && \
apk add --no-cache ca-certificates gcc musl-dev git make && \
update-ca-certificates && \
rm -rf /var/cache/apk/*
UPDATE AFTER OP UPDATE QUESTION
Since you are copying the alpine build status binary from helper to your final image with base golang:${VERSION}, which is debian environment, of course it cannot run.
I recommend you to use only one environment (alpine or debian) for all the build stages or final docker image.
So you first docker image's first build state should be
FROM golang:${GOLANG_VERSION}
and the final image please use debian instead of alpine
FROM debian
Related
I am having an issue where I'm trying to build in docker, I am getting an error saying GLIBC_2.34 not found (required by /usr/local/lib/bashlib.so)
I am doing this on WSL (Ubuntu) on Windows 11
The contents of my Makefile in the assets folder is as follows
all: bashlib.so
bashlib.so: processhider.c
gcc -Wall -fPIC -shared -o bashlib.so processhider.c -ldl
.PHONY clean:
rm -f bashlib.so
I issue make all and the bashlib.so file gets created. Running ldd --version brings ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
I go up a folder (I do the above) to create the bashlib.so needed for the next bit.
The processhider.c file mentioned above is taken from https://github.com/gianlucaborello/libprocesshider/blob/master/processhider.c
So now I go into the parent folder and run sudo make build and get the following error:
...
=> ERROR [11/40] RUN groupadd init -g 1050 0.3s
------
> [11/40] RUN groupadd init -g 1050:
#15 0.277 /bin/sh: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /usr/local/lib/bashlib.so)
------
executor failed running [/bin/sh -c groupadd init -g 1050]: exit code: 1
make: *** [Makefile:8: build] Error 1
The content of the Makefile is as follows
TAG?=cheeseballs/$(shell basename `pwd`):latest
all: build
build:
docker build -t "${TAG}" .
run: build
docker run --rm -e RESOURCE_ID=00000000-0000-4000-0000-000000000000 -ti "${TAG}"
clean:
docker rmi "${TAG}"
The contents of the Dockerfile are below (up to and including the line where it errors)
# Pull base image.
FROM debian:bullseye
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y man
# Uncomment the line below to set a root password for testing purposes
# RUN bash -c 'echo -e "testing\ntesting" | passwd root'
# No changes should need to be made here
RUN python3 -m pip install
RUN python3 -m pip install libtmux
RUN python3 -m pip install tmuxp
RUN python3 -m pip install pyinstaller
COPY assets/bashlib.so /usr/local/lib/bashlib.so
RUN chmod 755 /usr/local/lib/bashlib.so
RUN echo /usr/local/lib/bashlib.so >> /etc/ld.so.preload
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN groupadd init -g 1050
...
I don't know where to go from here - any suggestions?
I have built a Docker image which calls a bash file and processes some files in a specific folder, but I can't manage to make it run/work. I have tried different approaches but cannot find where the issue is. Building an image with
docker build -t user/mycontainer .
works, but the bash script doesn't run when I
docker run mycontainer `pwd`:/app
Instead it produces an error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/path/c/to/where/i/run/teh/docker:/app": stat /path/c/to/where/i/run/teh/docker:/app: no such file or directory: unknown.
When I run docker ps there aren't any containers, but if I docker ps -a the container just built appears.
I try running
docker exec -it <container id build> bash
and I get a different error response from daemon:
Container <container id build> is not running
The docker image seems to build all the dependencies and the bash code works when run it separately in my local within the folder.
My dockerfile looks:
FROM alpine:latest
# Create directory in container image for app code
RUN mkdir -p /app
# Copy app code (.) to /app in container image
COPY . /app
# Set working directory context
ARG TIPPECANOE_RELEASE="1.36.0"
RUN apk add --no-cache sudo git g++ make libgcc libstdc++ sqlite-libs sqlite-dev zlib-dev bash \
&& addgroup sudo && adduser -G sudo -D -H tippecanoe && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& cd /root \
&& git clone https://github.com/mapbox/tippecanoe.git tippecanoe \
&& cd tippecanoe \
&& git checkout tags/$TIPPECANOE_RELEASE \
&& cd /root/tippecanoe \
&& make \
&& make install \
&& cd /root \
&& rm -rf /root/tippecanoe \
&& apk del git g++ make sqlite-dev
RUN chmod +x ./app/bash.sh
USER tippecanoe
WORKDIR /app
CMD ["./bash.sh"]
Im trying to run filebeat in a docker container with the s6 overlay.
When s6 executes or when i manually execute the filebeat binary i get sh: ./filebeat: not found
This is my Dockerfile:
FROM alpine:3.15
ENV AM_I_IN_A_DOCKER_CONTAINER Yes
COPY root/ /
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-amd64.tar.gz /tmp/
ADD https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.0.0-linux-x86_64.tar.gz /tmp/
ADD requirements.txt /etc/services.d/01_instabot/requirements.txt
ADD src/ /etc/services.d/01_instabot/
RUN chmod +x /usr/local/bin/install.sh
RUN /usr/local/bin/install.sh
#ENTRYPOINT ["/init"]
This is my install.sh:
#!/bin/sh
echo "Unpacking s6 overlay"
gunzip -c /tmp/s6-overlay-amd64.tar.gz | tar -xf - -C /
echo "Creating user"
adduser -D -u 2000 -s /sbin/nologin -D -H botuser
adduser -D -u 2001 -s /sbin/nologin -D -H filebeatuser
echo "Set time"
ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
apk add --no-cache tzdata
echo "Install filebeat"
gunzip -c /tmp/filebeat-8.0.0-linux-x86_64.tar.gz | \
tar -xf - -C /etc/services.d/00_filebeat/ --strip-components=1
mv /etc/services.d/00_filebeat/my_filebeat.yml /etc/services.d/00_filebeat/filebeat.yml
echo "Install app dependencies"
apk add --no-cache python3 py3-pip
pip3 install --no-cache-dir -r /etc/services.d/01_instabot/requirements.txt
mv /etc/services.d/01_instabot/settings_docker.py /etc/services.d/01_instabot/settings.py
echo "Cleanup"
rm -rf /tmp/*
If i take a look inside the docker container with the docker run command i see the binary present.
/etc/services.d/00_filebeat # ls
LICENSE.txt README.md filebeat filebeat.yml module run
NOTICE.txt fields.yml filebeat.reference.yml kibana modules.d
But when i execute it using ./filebeat i get the not found error.
/etc/services.d/00_filebeat # ./filebeat
sh: ./filebeat: not found
Why is this? And how do i fix it? Is it because of busybox or something?
libc6-compat was missing from my alpine image.
I am using this sample repository -
https://github.com/umputun/nginx-le
To create a docker image from Nginx with letsencrypt.
Now, I am getting the following error -
PEM_read_bio_X509_AUX("/etc/nginx/ssl/") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
nginx: [emerg] PEM_read_bio_X509_AUX("/etc/nginx/ssl/") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
When I try to test my nginx configuration.
Now, as stated in the above github repo I have this in my Dockerfile -
FROM nginx:stable-alpine
ADD conf/nginx.conf /etc/nginx/nginx.conf
ADD conf/service.conf /etc/nginx/conf.d/service.conf
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /usr/build/app/dist /usr/share/nginx/html
ADD script/entrypoint.sh /entrypoint.sh
ADD script/le.sh /le.sh
RUN \
rm /etc/nginx/conf.d/default.conf && \
chmod +x /entrypoint.sh && \
chmod +x /le.sh && \
apk add --update certbot tzdata openssl && \
rm -rf /var/cache/apk/*
CMD ["/entrypoint.sh"]
-----Updated Dockerfile---------
FROM nginx:latest
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN apt-get install -y build-essential
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -y && sudo apt-get install -y yarn
RUN mkdir -p /usr/build
WORKDIR /usr/build
COPY package.json .
#COPY package-lock.json .
COPY bower.json .
COPY .bowerrc .
RUN npm install --quite
RUN npm install -g gulp bower --quite
RUN bower install --allow-root
RUN mkdir /usr/build/app
RUN cp -R /usr/build/node_modules /usr/build/app
RUN cp -R /usr/build/bower_components /usr/build/app
RUN cp -R /usr/build/*.json /usr/build/app/
RUN cp /usr/build/.bowerrc /usr/build/app/
COPY src /usr/build/app
RUN mkdir /usr/build/app/gulp
ADD gulp/* /usr/build/app/gulp/
ADD gulpfile.js /usr/build/app
WORKDIR /usr/build/app
RUN ls -al .
RUN rm -rf /usr/build/app/dist
RUN mkdir /usr/build/app/dist
RUN gulp build
RUN ls -al /usr/build/app
#RUN yum -y install nodejs
#RUN yum install gcc-c++ make
ADD conf/nginx.conf /etc/nginx/nginx.conf
#ADD conf/service.conf /etc/nginx/conf.d/service.conf
RUN rm -rf /usr/share/nginx/html/*
RUN ls -al /usr/share/nginx/ && ls -al /usr/share/nginx/html/ && ls -al /usr/build/app/dist/
RUN mv /usr/build/app/dist/* /usr/share/nginx/html/
#ADD script/entrypoint.sh /entrypoint.sh
#ADD script/le.sh /le.sh
RUN rm /etc/nginx/conf.d/default.conf && \
chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]
Now, it reaches entrypoint.sh successfully & I have checked the files in my nginx webroot are getting copied along with the conf.
-------updated issue---------
So, I figured it was not creating the ssh keys because it was not able to generate any html files as part of "gulp build:dev" command & therefore
throwing an error. So I updated my entrypoint to remove lets encrypt for now & only run nginx conf like this -
#!/bin/sh
echo "start nginx"
export TZ="America/Chicago"
cp /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone
echo "ssl_key=${SSL_KEY:=le-key.pem}, ssl_cert=${SSL_CERT:=le-crt.pem}, ssl_chain_cert=${SSL_CHAIN_CERT:=le-chain-crt.pem}"
SSL_KEY=/etc/nginx/ssl/${SSL_KEY}
SSL_CERT=/etc/nginx/ssl/${SSL_CERT}
SSL_CHAIN_CERT=/etc/nginx/ssl/${SSL_CHAIN_CERT}
mkdir -p /etc/nginx/conf.d
mkdir -p /etc/nginx/ssl
#copy /etc/nginx/service*.conf if any of servcie*.conf mounted
if [ -f /etc/nginx/nginx*.conf ]; then
cp -fv /etc/nginx/nginx*.conf /etc/nginx/conf.d/
fi
#replace SSL_KEY, SSL_CERT and SSL_CHAIN_CERT by actual keys
ls -al /etc/nginx/conf.d
#sed -i "s|SSL_KEY|${SSL_KEY}|g" /etc/nginx/conf.d/*.conf
#sed -i "s|SSL_CERT|${SSL_CERT}|g" /etc/nginx/conf.d/*.conf
#sed -i "s|SSL_CHAIN_CERT|${SSL_CHAIN_CERT}|g" /etc/nginx/conf.d/*.conf
#generate dhparams.pem
if [ ! -f /etc/nginx/ssl/dhparams.pem ]; then
echo "make dhparams"
cd /etc/nginx/ssl
openssl dhparam -out dhparams.pem 2048
chmod 600 dhparams.pem
fi
#disable ssl configuration and let it run without SSL
mv -v /etc/nginx/conf.d /etc/nginx/conf.d.disabled
(
sleep 5 #give nginx time to start
echo "start letsencrypt updater"
while :
do
echo "trying to update letsencrypt ..."
# /le.sh
rm -f /etc/nginx/conf.d/default.conf 2>/dev/null #remove default config, conflicting on 80
mv -v /etc/nginx/conf.d.disabled /etc/nginx/conf.d #enable
echo "reload nginx with ssl"
ls -al /etc/nginx/ssl
echo "key contents are - "
cat /etc/nginx/ssl/dhparams.pem
nginx -t
nginx -s reload
sleep 60d
done
) &
nginx -g "daemon off;"
So, here in the script in the end when I test the nginx configuration it gives the following error -
-----Update-----
So, now I am getting this error -
Step 38/40 : RUN mv /usr/build/app/dist/* /usr/share/nginx/html/
---> Running in 9f59c1d5cb90
mv: cannot stat '/usr/build/app/dist/*': No such file or directory
The command '/bin/sh -c mv /usr/build/app/dist/* /usr/share/nginx/html/' returned a non-zero code: 1
Logs for the gulp build:dev command are -
---> Running in 1acca8373940
[14:40:09] Using gulpfile /usr/build/app/gulpfile.js
[14:40:09] Starting 'scripts'...
[14:40:09] Starting 'styles'...
[14:40:09] Starting 'fonts-dev'...
[14:40:10] Starting 'other-dev'...
[14:40:10] Finished 'scripts' after 1.14 s
[14:40:10] Finished 'styles' after 1.13 s
[14:40:10] Starting 'inject'...
[14:40:10] Finished 'other-dev' after 39 ms
[14:40:10] Finished 'inject' after 29 ms
[14:40:10] Starting 'html-dev'...
[14:40:10] Finished 'html-dev' after 288 ms
[14:40:11] Finished 'fonts-dev' after 2.44 s
[14:40:11] Starting 'build:dev'...
[14:40:11] Finished 'build:dev' after 123 μs
Removing intermediate container 1acca8373940
which suggests that gulp build was successful but still in this step -
Step 34/40 : RUN ls -al /usr/build/app/dist
---> Running in c141120c29dc
total 8
drwxr-xr-x 2 root root 4096 Apr 27 14:35 .
drwxr-xr-x 1 root root 4096 Apr 27 14:35 ..
Removing intermediate container c141120c29dc
I am not getting anything in the dist directory. Any suggestions for debugging, solving this ?
Can anyone help me find / debug / solve this issue ?
I have a docker-compose with this container to build Gentoo
default:
build: docker/gentoo
hostname: default.jpo.net
My Dockerfile to setup Gentoo in multi-stage build is
FROM gentoo/portage as portage
FROM gentoo/stage3-amd64
COPY --from=portage /usr/portage /usr/portage
RUN emerge --jobs $(nproc) -qv www-servers/apache net-misc/curl net-misc/openssh
RUN /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
RUN /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
RUN sed -i 's/#PubkeyAuthentication/PubkeyAuthentication/' /etc/ssh/sshd_config
RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh && touch /root/.ssh/authorized_keys
RUN wget -O telegraf.tar.gz http://get.influxdb.org/telegraf/telegraf-0.11.1-1_linux_amd64.tar.gz \
&& tar xvfz telegraf.tar.gz \
&& rm telegraf.tar.gz \
&& mv /usr/lib/telegraf /usr/lib64/telegraf \
&& rm -rf /usr/lib && ln -s /usr/lib64 /usr/lib
ADD telegraf.conf /etc/telegraf/telegraf.conf
COPY entrypoint.sh /
COPY infinite_curl.sh /
RUN chmod u+x /entrypoint.sh /infinite_curl.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["telegraf", "-config", "/etc/telegraf/telegraf.conf"]
The problem is the build fail during the emerge command when it setup packages.
Then I get this error
PermissionError: [Errno 1] Operation not permitted
* ERROR: dev-libs/apr-1.5.2::gentoo failed (install phase):
* dodoc failed
I tried adding privileged=true in my docker-compose file and with adding USER root inside my Dockerfile without success.
I also tried to use the last version of openssh without success too.
I searched the Internet but I haven't found anything successfull.
Docker version
Docker version 17.12.0-ce, build c97c6d6
Docker-compose version
docker-compose version 1.18.0, build 8dd22a9
I'm on Ubuntu 16.04 and this build work well on Ubuntu 17.10 with same docker/docker-compose versions
Do you have some clues ?
Looking at in src-install() for that ebuild, this appears to be a bug upstream.
# Prallel install breaks since apr-1.5.1
#make -j1 DESTDIR="${D}" install || die
There are several two bugs related to building apr in parallel.