-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile to enable cross-compiling in MacOS.
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
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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 |