Skip to content

Commit

Permalink
Add Dockerfile to enable cross-compiling in MacOS.
Browse files Browse the repository at this point in the history
In some cases for dev purposes we need to be able to produce linux compatible binary from MacOS system.
GOOS=linux is not enough witch our c-deps.
  • Loading branch information
suizman committed Mar 26, 2019
1 parent 85fca47 commit def4f8a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Exclude stuff to avoid large Docker context.
**qed
storage
!storage
**riot
**prometheus
**/.git
**/.terraform
c-deps/jemalloc
c-deps/libs
c-deps/snappy
c-deps/rocksdb
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2018-2019 Banco Bilbao Vizcaya Argentaria, S.A.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.12.1

ENV GO111MODULE=on
ENV CGO_LDFLAGS_ALLOW='.*'

WORKDIR /go/src/github.com/bbva/qed

# Install deps.
RUN apt update -qq && apt install -qq -y autoconf cmake

# Build C deps.
# This step acts as cache to avoid recompiling when Go code changes.
RUN git clone https://github.com/BBVA/qed.git /tmp/qed &&\
cd /tmp/qed &&\
git submodule update --init --recursive &&\
cd c-deps &&\
./builddeps.sh

# Warm Go modules cache.
RUN cd /tmp/qed &&\
go mod download

# Copy QED source from current working dir.
COPY . /go/src/github.com/bbva/qed

# Move C deps to current working dir.
RUN mv /tmp/qed/c-deps/* c-deps/

# Build QED binary
RUN go build -o /usr/local/bin/qed

# Clean
RUN rm -rf /var/lib/apt/lists/* /tmp/qed

0 comments on commit def4f8a

Please sign in to comment.