Skip to content

Commit

Permalink
Update push workflow (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejfitzgerald authored Aug 7, 2020
1 parent 1754888 commit 7ef9e4a
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 106 deletions.
43 changes: 15 additions & 28 deletions .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,34 @@ on:
tags:
- '*'

env:
REGISTRY: gcr.io/fetch-ai-images

jobs:
build-and-push:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Get tag name
id: tag_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Login to Docker hub, build and push
- name: Login to Docker Hub
run: |
SHORTVERSION=${SOURCE_TAG%.*}
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
docker build -t fetchai/fetchd:$SOURCE_TAG -f Dockerfile.hub .
docker push fetchai/fetchd:$SOURCE_TAG
docker tag fetchai/fetchd:$SOURCE_TAG fetchai/fetchd:$SHORTVERSION
docker push fetchai/fetchd:$SHORTVERSION
env:
SOURCE_TAG: ${{ steps.tag_name.outputs.SOURCE_TAG }}
- name: Build and Publish Public Images
uses: ejfitzgerald/[email protected]
with:
repo: fetchai/fetchd
target: hub

- name: Setup GCloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GCLOUD_KEY_IMAGES }}
- name: Configure Docker

- name: Login to GCR Registry
run: |
gcloud auth configure-docker
- name: Build and push to GCR
run: |
SHORTVERSION=${SOURCE_TAG%.*}
docker build -t $REGISTRY/fetchd:$SOURCE_TAG -f Dockerfile.gcr . --build-arg VERSION=$SOURCE_TAG
docker push $REGISTRY/fetchd:$SOURCE_TAG
docker tag $REGISTRY/fetchd:$SOURCE_TAG $REGISTRY/fetchd:$SHORTVERSION
docker push $REGISTRY/fetchd:$SHORTVERSION
env:
SOURCE_TAG: ${{ steps.tag_name.outputs.SOURCE_TAG }}
- name: Build and Publish Private Images
uses: ejfitzgerald/[email protected]
with:
repo: gcr.io/fetch-ai-images/fetchd
target: gcr
66 changes: 30 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,44 @@
# docker build . -t fetchai/fetchd:latest
# docker run --rm -it fetchai/fetchd:latest /bin/sh
FROM cosmwasm/go-ext-builder:0.8.2-alpine AS builder
FROM golang:1.14-buster as builder

RUN apk add git
# without this, build with LEDGER_ENABLED=false
RUN apk add libusb-dev linux-headers
# Set up dependencies
ENV PACKAGES jq curl wget jq file make git libgmp-dev gcc g++ swig libboost-serialization-dev

# copy all code into /code
WORKDIR /code
COPY . /code
RUN apt-get update && \
apt-get install -y $PACKAGES && \
git clone https://github.com/herumi/mcl && cd mcl && make install && ldconfig

# download all deps
RUN go mod download
# TODO: how to use this instead of hardcoding GO_COSMWASM
RUN basename $(ls -d /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@v*)
WORKDIR /cosmwasm
COPY . .
RUN make install

ENV GO_COSMWASM="v0.9.1"
# ##################################

# build go-cosmwasm *.a and install it
WORKDIR /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}
RUN cargo build --release --features backtraces --example muslc
RUN mv /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}/target/release/examples/libmuslc.a /lib/libgo_cosmwasm_muslc.a
# I got errors from go mod verify (called from make build) if I didn't clean this up
RUN rm -rf /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}/target
FROM debian:buster as hub

# build the go wasm binary
WORKDIR /code
# Set up dependencies
ENV PACKAGES jq curl libgmpxx4ldbl libboost-serialization1.67.0

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN BUILD_TAGS=muslc make build
RUN apt-get update && \
apt-get install -y $PACKAGES

FROM alpine:3.12
COPY --from=builder /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@v*/api/libgo_cosmwasm.so /usr/lib/libgo_cosmwasm.so
COPY --from=builder /go/bin/fetchcli /usr/bin/fetchcli
COPY --from=builder /go/bin/fetchd /usr/bin/fetchd
COPY --from=builder /usr/local/lib/libmcl.so /usr/lib
COPY entrypoints/entrypoint.sh /usr/bin/entrypoint.sh

COPY --from=builder /code/build/fetchd /usr/bin/fetchd
COPY --from=builder /code/build/fetchcli /usr/bin/fetchcli
VOLUME /root/.fetchd
VOLUME /root/secret-temp-config

COPY docker/* /opt/
RUN chmod +x /opt/*.sh

WORKDIR /opt

# rest server
ENTRYPOINT [ "/usr/bin/entrypoint.sh" ]
EXPOSE 1317
# tendermint p2p
EXPOSE 26656
# tendermint rpc
EXPOSE 26657
STOPSIGNAL SIGTERM

# ##################################

FROM hub as gcr

CMD ["/usr/bin/fetchd version"]
COPY ./entrypoints/run-node.sh /usr/bin/run-node.sh
COPY ./entrypoints/run-server.sh /usr/bin/run-server.sh
5 changes: 0 additions & 5 deletions Dockerfile.gcr

This file was deleted.

35 changes: 0 additions & 35 deletions Dockerfile.hub

This file was deleted.

4 changes: 2 additions & 2 deletions build_local.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

docker build -t fetchai/fetchd:test -f Dockerfile.hub .
docker build -t local-fetchd:test -f Dockerfile.gcr . --build-arg VERSION=test
docker build -t fetchai/fetchd:test --target hub .
docker build -t local-fetchd:test --target gcr .
50 changes: 50 additions & 0 deletions ref.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# docker build . -t fetchai/fetchd:latest
# docker run --rm -it fetchai/fetchd:latest /bin/sh
FROM cosmwasm/go-ext-builder:0.8.2-alpine AS builder

RUN apk add git
# without this, build with LEDGER_ENABLED=false
RUN apk add libusb-dev linux-headers

# copy all code into /code
WORKDIR /code
COPY . /code

# download all deps
RUN go mod download
# TODO: how to use this instead of hardcoding GO_COSMWASM
RUN basename $(ls -d /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@v*)

ENV GO_COSMWASM="v0.9.1"

# build go-cosmwasm *.a and install it
WORKDIR /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}
RUN cargo build --release --features backtraces --example muslc
RUN mv /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}/target/release/examples/libmuslc.a /lib/libgo_cosmwasm_muslc.a
# I got errors from go mod verify (called from make build) if I didn't clean this up
RUN rm -rf /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}/target

# build the go wasm binary
WORKDIR /code

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN BUILD_TAGS=muslc make build

FROM alpine:3.12

COPY --from=builder /code/build/fetchd /usr/bin/fetchd
COPY --from=builder /code/build/fetchcli /usr/bin/fetchcli

COPY docker/* /opt/
RUN chmod +x /opt/*.sh

WORKDIR /opt

# rest server
EXPOSE 1317
# tendermint p2p
EXPOSE 26656
# tendermint rpc
EXPOSE 26657

CMD ["/usr/bin/fetchd version"]

0 comments on commit 7ef9e4a

Please sign in to comment.