Last active
March 18, 2019 09:10
-
-
Save ali-ince/505612e22b2a641219181494645aa816 to your computer and use it in GitHub Desktop.
A Dockerfile that enables seabolt compilation on arch linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM archlinux/base AS build-openssl-with-static | |
# Install required packages for re-building openssl with static libraries enabled | |
RUN pacman -Syyu --noconfirm base-devel asp && useradd -m -d /pkg-build pkg-build | |
# Update makepkg.conf to enable static libraries | |
RUN sed -i -e 's/!staticlibs/staticlibs/g' /etc/makepkg.conf | |
# Trust pgp key for the openssl source | |
RUN su -c "gpg --recv-keys 8657ABB260F056B1E5190839D9C4D26D0E604491" - pkg-build | |
# Export openssl package definition | |
RUN su -c "asp export openssl" - pkg-build | |
# Build and create a package that includes static libraries | |
RUN su -c "cd openssl && makepkg" - pkg-build | |
FROM archlinux/base AS build-seabolt | |
# Copy built package from the previous layer | |
COPY --from=build-openssl-with-static /pkg-build/openssl/openssl*.pkg.tar.xz /tmp | |
# Install it, which brings in the static openssl libraries | |
RUN pacman -U --noconfirm /tmp/openssl*.pkg.tar.xz | |
# Install required packages for seabolt | |
RUN pacman -Syuu --noconfirm base-devel cmake git | |
RUN git clone -b 1.7 https://github.com/neo4j-drivers/seabolt /tmp/seabolt | |
WORKDIR /tmp/seabolt/build-docker | |
RUN cmake -D CMAKE_BUILD_TYPE=Release .. && cmake --build . --target package | |
FROM archlinux/base AS build-go | |
# Copy built openssl package from the build-openssl-with-static layer | |
COPY --from=build-openssl-with-static /pkg-build/openssl/openssl*.pkg.tar.xz /tmp | |
# Copy built seabolt package from the build-seabolt layer | |
COPY --from=build-seabolt /tmp/seabolt/build-docker/dist-package/seabolt*.tar.gz /tmp | |
# Install required packages for seabolt | |
RUN pacman -Syuu --noconfirm gcc tar go pkgconfig git | |
RUN pacman -U --noconfirm /tmp/openssl*.pkg.tar.xz | |
RUN tar zxvf /tmp/seabolt*.tar.gz --strip-components=1 -C / | |
RUN mkdir -p /root/go/bin | |
# install dep | |
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | |
# get the sample source code from gist | |
WORKDIR /root/go/src/blog | |
ADD https://gist.githubusercontent.com/ali-ince/baefaf990f7baedadece133520f31310/raw/bc2087227f600d547d4cab80afd2d872f462f1eb/completed.go main.go | |
# install dependencies | |
RUN /root/go/bin/dep init && /root/go/bin/dep ensure -add github.com/neo4j/neo4j-go-driver/neo4j | |
# build statically linked executable | |
RUN PKG_CONFIG_PATH=/usr/local/share/pkgconfig go build -o sample -tags seabolt_static main.go | |
# base the image to neo4j | |
FROM archlinux/base | |
# copy the statically linked executable | |
COPY --from=build-go /root/go/src/blog/sample /blog/sample | |
ENTRYPOINT ["/blog/sample"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment