We want to build gopacket for Linux under MacOS.
What we have tried.
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build
Errors
..gopacket/pcap/pcap.go:30:22: undefined: pcapErrorNotActivated
..gopacket/pcap/pcap.go:52:17: undefined: pcapTPtr
..gopacket/pcap/pcap.go:64:10: undefined: pcapPkthdr
Try to do cross compile through docker golang-crossbuild
docker run -it --rm \
-v /Users/my/server:/go/src/my/server \
-w /go/src/my/server \
-e CGO_ENABLED=1 \
-e CGO_LDFLAGS+="-L/libpcap/libpcap-1.8.1-amd64" \
docker.elastic.co/beats-dev/golang-crossbuild:1.16.4-main \
--build-cmd "GOOS=linux GOARCH=amd64 go build . " \
-p "linux/amd64"
Errors
...pcap/pcap_unix.go:34:18: fatal error: pcap.h: No such file or directory
#include <pcap.h>
^
compilation terminated.
Is there any better way to do cross compile gopacket for linux under MacOS?
Finally, we solve it after installing libpcap-dev
First, we build one new docker based on golang-crossbuild
Dockerfile
FROM docker.elastic.co/beats-dev/golang-crossbuild:1.16.4-main
RUN apt-get update && apt-get install -y libpcap-dev
build script is
docker run -it --rm \
-v /Users/my/server:/go/src/my/server \
-w /go/src/my/server \
-e CGO_ENABLED=1 \
-e CC=aarch64-linux-gnu-gcc \
-e CGO_LDFLAGS+="-L/libpcap/libpcap-1.8.1" \
golang-new-builder:latest \
--build-cmd "GOOS=linux GOARCH=amd64 go build . " \
-p "linux/amd64"
Related
I have a stage in Jenkinsfile to run some ruby test files using rake test. But the tests are taking too long, so I am planning to implement the parallel running of individual tests. But I am getting an error while executing individual tests in parallel stages.
All the test cases are ran using rake test when we are in lib folder.
Individual test cases are ran using ruby test1.rb when we are in lib/test folder.
Currently working Jenkinsfile :
stage('Test Image') {
steps {
script {
sh "docker run --rm --entrypoint '' -v \${AWS_CONFIG_FILE:-/home/ubuntu/.aws/config}:/root/.aws/config:ro -v \${AWS_SHARED_CREDENTIALS_FILE:-/home/ubuntu/.aws/credentials}:/root/.aws/credentials:ro -v ${WORKSPACE}/test-results:/srv/www/lib/test/html_reports ${IMAGE_NAME} rake test"
}
}
}
Modified Jenkinsfile with Parallel tests:
stage('Test the Image') {
parallel {
stage('Test1'){
steps {
script {
sh "docker run --rm --entrypoint '' -v \${AWS_CONFIG_FILE:-/home/ubuntu/.aws/config}:/root/.aws/config:ro -v \${AWS_SHARED_CREDENTIALS_FILE:-/home/ubuntu/.aws/credentials}:/root/.aws/credentials:ro -v ${WORKSPACE}/test-results:/srv/www/lib/test/html_reports docker exec -it ${IMAGE_NAME} bash -c 'cd test && ruby test1.rb'"
}
}
}
stage('Test2'){
steps {
script {
sh "docker run --rm --entrypoint '' -v \${AWS_CONFIG_FILE:-/home/ubuntu/.aws/config}:/root/.aws/config:ro -v \${AWS_SHARED_CREDENTIALS_FILE:-/home/ubuntu/.aws/credentials}:/root/.aws/credentials:ro -v ${WORKSPACE}/test-results:/srv/www/lib/test/html_reports docker exec -it ${IMAGE_NAME} bash -c 'cd test && ruby test2.rb'"
}
}
}
}
}
Error: docker exec\": executable file not found in $PATH":
Docker file:
FROM ruby:2.5.3 as build
RUN apt-get update && \
apt-get install -qy \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update && \
apt-get install -qy \
docker-ce \
docker-ce-cli \
containerd.io \
build-essential \
libldap-dev \
libsasl2-dev \
libxml2-dev \
libxslt-dev \
libldap2-dev \
libsasl2-dev \
git \
jq
RUN curl -fsSL -o /usr/local/bin/aws-vault 'https://github.com/99designs/aws-vault/releases/download/v5.1.2/aws-vault-linux-amd64' && \
chmod 755 /usr/local/bin/aws-vault
RUN gem install bundler -v '2.0.2'
WORKDIR /tmp
COPY Gemfile* ./
RUN bundler install --without=development
FROM ruby:2.5.3-slim
RUN mkdir -p /srv/www/lib /srv/www/tmp/sockets /srv/www/tmp/pids
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /usr/local/bin/aws-vault /usr/local/bin/aws-vault
COPY --from=build /usr/bin/docker* /usr/bin/
COPY ops-cli2.rb /srv/www/lib/cli2.rb
ENV AWS_SHARED_CREDENTIALS_FILE=/root/.aws/credentials
WORKDIR /srv/www/lib
COPY . .
RUN ["chmod", "+x", "/srv/www/lib/cli2.rb"]
ENTRYPOINT ["/srv/www/lib/cli2.rb"]
I think you can just remove docker exec -it in your commandline
I unable to build jmeter docker file, getting below error.
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz: temporary error (try again later)
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz: temporary error (try again later)
ERROR: unsatisfiable constraints:
curl (missing):
required by: world[curl]
fontconfig (missing):
required by: world[fontconfig]
net-tools (missing):
required by: world[net-tools]
shadow (missing):
required by: world[shadow]
su-exec (missing):
required by: world[su-exec]
tcpdump (missing):
required by: world[tcpdump]
ttf-dejavu (missing):
required by: world[ttf-dejavu]
The command '/bin/sh -c chmod +x /usr/local/bin/entrypoint.sh && apk add --no-cache curl fontconfig net-tools shadow su-exec tcpdump ttf-dejavu && cd /tmp/ && curl --location --silent --show-error --output apache-jmeter-${JMETER_VERSION}.tgz ${MIRROR}/apache-jmeter-${JMETER_VERSION}.tgz && curl --location --silent --show-error --output apache-jmeter-${JMETER_VERSION}.tgz.sha512 ${MIRROR}/apache-jmeter-${JMETER_VERSION}.tgz.sha512 && sha512sum -c apache-jmeter-${JMETER_VERSION}.tgz.sha512 && mkdir -p /opt/ && tar x -z -f apache-jmeter-${JMETER_VERSION}.tgz -C /opt && rm -R -f apache* && sed -i '/RUN_IN_DOCKER/s/^# //g' ${JMETER_BIN}/jmeter && sed -i '/PrintGCDetails/s/^# /: "${/g' ${JMETER_BIN}/jmeter && sed -i '/PrintGCDetails/s/$/}"/g' ${JMETER_BIN}/jmeter && chmod +x ${JMETER_HOME}/bin/*.sh && jmeter --version && curl --location --silent --show-error --output /opt/alpn-boot-${ALPN_VERSION}.jar http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/${ALPN_VERSION}/alpn-boot-${ALPN_VERSION}.jar && rm -fr /tmp/*' returned a non-zero code: 7
Dockerfile:
FROM openjdk:8u201-jdk-alpine3.9
LABEL maintainer="emmanuel.gaillardon#orange.fr"
STOPSIGNAL SIGKILL
ENV MIRROR https://www-eu.apache.org/dist/jmeter/binaries
ENV JMETER_VERSION 5.1.1
ENV JMETER_HOME /opt/apache-jmeter-${JMETER_VERSION}
ENV JMETER_BIN ${JMETER_HOME}/bin
ENV ALPN_VERSION 8.1.13.v20181017
ENV PATH ${JMETER_BIN}:$PATH
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh \
&& apk add --no-cache \
curl \
fontconfig \
net-tools \
shadow \
su-exec \
tcpdump \
ttf-dejavu \
&& cd /tmp/ \
&& curl --location --silent --show-error --output apache-jmeter-${JMETER_VERSION}.tgz ${MIRROR}/apache-jmeter-${JMETER_VERSION}.tgz \
&& curl --location --silent --show-error --output apache-jmeter-${JMETER_VERSION}.tgz.sha512 ${MIRROR}/apache-jmeter-${JMETER_VERSION}.tgz.sha512 \
&& sha512sum -c apache-jmeter-${JMETER_VERSION}.tgz.sha512 \
&& mkdir -p /opt/ \
&& tar x -z -f apache-jmeter-${JMETER_VERSION}.tgz -C /opt \
&& rm -R -f apache* \
&& sed -i '/RUN_IN_DOCKER/s/^# //g' ${JMETER_BIN}/jmeter \
&& sed -i '/PrintGCDetails/s/^# /: "${/g' ${JMETER_BIN}/jmeter && sed -i '/PrintGCDetails/s/$/}"/g' ${JMETER_BIN}/jmeter \
&& chmod +x ${JMETER_HOME}/bin/*.sh \
&& jmeter --version \
&& curl --location --silent --show-error --output /opt/alpn-boot-${ALPN_VERSION}.jar http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/${ALPN_VERSION}/alpn-boot-${ALPN_VERSION}.jar \
&& rm -fr /tmp/*
# Required for HTTP2 plugins
ENV JVM_ARGS -Xbootclasspath/p:/opt/alpn-boot-${ALPN_VERSION}.jar
WORKDIR /jmeter
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["jmeter", "--?"]
Can anyone please let me know if anything missing
The error indicates that Alpine apk package management tool wasn't able to install curl, fontconfig and other packages due to not being able to connect to http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/ host and get the files from there.
Ensure that your host machine has Internet and if it does follow recommendations from the My docker container has no internet answers.
Also be aware that currently JMeter 5.2 is out so I would recommend at least changing this line:
ENV MIRROR https://www-eu.apache.org/dist/jmeter/binaries
to this one:
ENV MIRROR https://archive.apache.org/dist/jmeter/binaries
otherwise your Dockerfile will not work even if you resolve Internet connectivity issues.
Optionally you can ramp-up JMETER_VERSION to match the latest stable JMeter release
Alpine-based JDK image you, in turn, are based on, is, actually, pretty basic (no pun intended!), it's stripped of pretty much everything beyond very core.
So, it just doesn't contain them utilities you're trying to use there - which it immediately reports back to you as missing.
On a bright side, though - it is really small, 5MB or so.
What you can do is two things:
1) Install the packages through Alpine package manager apk prior to using them (something like apk add curl, please figure out the exact package names yourself through apk search).
That's kinda 'official' Alpine way to handle cases like that.
2) Base on some more generic Linux images. It would grow much bigger though, tens of megabytes, to my recollection.
I have a python script that I'd want to run on 2 different containers running python 2.7 and python 3.6.
I want to use the same docker file to build 2 different images, with the difference being the python version(i.e one time it's FROM python:3.6 and the other is FROM python:2.7, and do it through a makefile.
Makefile
.PHONY = all clean build run
all: build run
# DOCKER TASKS
# Build the container
build: ## Build the container for tests
docker build -t myscript:python2.7 .
docker build -t myscript:python3.6 .
run: ## Run container
docker run myscript:python2.7
docker run myscript:python3.6
I have a Dockerfile for building the image:
Dockerfile
FROM python:3.6
WORKDIR /usr/local/bin
RUN pip install pytest
COPY myscript.py test_regex_script.py ./
CMD ["pytest", "test_regex_script.py"]
Since it's the same Docker file it's tricky, I was thinking to create two different Dockerfiles each with a different python version (and all the rest the same), but was wondering if there's more elegant way to do it.
thanks
You can use a build argument for it.
Your Dockerfile should look like this:
ARG VERSION=3.6
FROM python:3.6
WORKDIR /usr/local/bin
RUN pip install pytest
COPY myscript.py test_regex_script.py ./
CMD ["pytest", "test_regex_script.py"]
To build for 3.6:
docker build -t python-app:3.6 .
To build for 2.7:
docker build -t python-app:2.7 --build-arg VERSION=2.7 .
Note that 3.6 is the default version in case you don't specify one (ARG VERSION=3.6). You can also not assign a default value in which case you have to always pass a value in the build argument (--build-arg VERSION=...)
you can try updating the script mentioned above like
ARG PYTHON_VERSION=python:3.8-slim-buster
FROM python:${PYTHON_VERSION}
WORKDIR /usr/local/bin
RUN pip install pytest
COPY myscript.py test_regex_script.py ./
CMD ["pytest", "test_regex_script.py"]
Make sure ARG is at the very top of your Dockerfile.
ARG PY_VERSION=3.8
ARG NODE_VERSION=16
FROM node:$NODE_VERSION as frontend
FROM python:$PY_VERSION as backend
The FROM's can be lower in the file.
Default (python:3.8 and node:16):
docker build \
-t my-image \
-f Dockerfile \
.
Override Python (use 3.10 instead of 3.8):
docker build \
-t my-image \
-f Dockerfile \
--build-arg PY_VERSION=3.10 \
.
Override Node:
docker build \
-t my-image \
-f Dockerfile \
--build-arg NODE_VERSION=17 \
.
Override Both:
docker build \
-t my-image \
-f Dockerfile \
--build-arg PY_VERSION=3.10 \
--build-arg NODE_VERSION=17 \
.
You can also use buildx / docker buildx build:
docker buildx build \
-t my-image \
-f Dockerfile \
--build-arg PY_VERSION=3.10 \
--build-arg NODE_VERSION=17 \
.
Excuse me.
I try to run code using gtkmm-2.4 inside a docker for Mac. I tried it with refer to this site.(https://fredrikaverpil.github.io/2016/07/31/docker-for-mac-and-gui-applications/)
I see the following error:
Gtk-WARNING **: cannot open display: 192.168.1.11:0
Dockerfile
FROM debian
RUN apt-get update && apt-get install -y \
automake \
build-essential \
dpkg-sig \
libgtkmm-2.4-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# cleanup
RUN apt-get -qy autoremove
setting:
ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + $ip
docker run:
docker run --rm -e DISPLAY=$ip:0 \
-it -v /tmp/.X11-unix:/tmp/.X11-unix my_image /bin/bash
and the error in docker:
g++ GtkmmTest.cpp -o GtkmmTest `pkg-config gtkmm-2.4 --cflags --libs`
./GtkmmTest
(GtkmmTest:607): Gtk-WARNING **: cannot open display: 192.168.1.11:0
echo $DISPLAY
192.168.1.11:0
I thank you in advance for your reply.
I am using this http://fhirtest.uhn.ca/baseDstu2 test FHIR server and it worked okay so far.
Now I am getting an HTTP-500 - Failed to Call Access Method exception.
Anyone has any idea on what has gone wrong?
This happens frequently. Probably because someone tested weird queries or similar that put the server in an unstable status.
I suggest posting a comment in https://chat.fhir.org/#narrow/stream/hapi to get the server restarted,
or install http://hapifhir.io/doc_cli.html which does basically the same but you have full control.
I built a Dockerfile:
FROM debian:sid
MAINTAINER Günter Zöchbauer <guenter#yyy.com>
ENV DEBIAN_FRONTEND noninteractive
RUN \
apt-get -q update && \
DEBIAN_FRONTEND=noninteractive && \
apt-get install --no-install-recommends -y -q \
apt-transport-https \
apt-utils \
wget \
bzip2 \
default-jdk
# net-tools sudo procps telnet
RUN \
apt-get update && \
rm -rf /var/lib/apt/lists/*
https://github.com/jamesagnew/hapi-fhir/releases/download/v2.0/hapi-fhir-2.0-cli.tar.bz2 && \
ADD hapi-* /hapi_fhir_cli/
RUN ls -la
RUN ls -la /hapi_fhir_cli
ADD prepare_server.sh /hapi_fhir_cli/
RUN \
cd /hapi_fhir_cli && \
bash -c /hapi_fhir_cli/prepare_server.sh
ADD start.sh /hapi_fhir_cli/
WORKDIR /hapi_fhir_cli
EXPOSE 5555
ENTRYPOINT ["/hapi_fhir_cli/start.sh"]
Which requires in the same directory as the Dockerfile
prepare_server.sh
#!/usr/bin/env bash
ls -la
./hapi-fhir-cli run-server --allow-external-refs &
while ! timeout 1 bash -c "echo > /dev/tcp/localhost/8080"; do sleep 10; done
./hapi-fhir-cli upload-definitions -t http://localhost:8080/baseDstu2
./hapi-fhir-cli upload-examples -c -t http://localhost:8080/baseDstu2
start.sh
#!/usr/bin/env bash
cd /hapi_fhir_cli
./hapi-fhir-cli run-server --allow-external-refs -p 5555
Build
docker build myname/hapi_fhir_cli_dstu2 -t . #--no-cache
Run
docker run -d -p 5555:5555 [image id from docker build]
Hope this helps.