Skip to content

Docker build #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CMake ignores
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps

# Project specific
cmake/*
!cmake/.gitkeep
node_modules
.idea

# protoc output
gooseai/*/*pb*
24 changes: 24 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build Docker Image

on:
push: {}

jobs:
build-with-docker:
name: Build with Docker
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v3
with:
push: false
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: |
type=local,dest=${{ runner.temp }}/docker-build
- uses: actions/upload-artifact@v3
with:
name: gooseai
path: ${{ runner.temp }}/docker-build/gooseai
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG NODE_IMAGE_TAG=16-bullseye
FROM node:${NODE_IMAGE_TAG} as builder
ARG GOLANG_VERSION=1.18.6
ARG GOLANG_PACKAGE=https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz
ARG GRPC_VERSION=v1.48.2
ARG PROTOC_GEN_GO_VERSION=v1.28.1
ARG PROTOC_GEN_GO_GRPC_VERSION=v1.1.0

# Install python and build tools from apt
RUN apt-get update && apt-get install -y cmake git build-essential python3-venv wget && rm -rf /var/lib/apt/lists/*

# Install golang from binary package
RUN rm -rf /go && wget ${GOLANG_PACKAGE} -qO- | tar -C / -xz
ENV GOPATH=/go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
RUN mkdir -p /build

# Build GRPC; note this issue before updating: https://github.com/protocolbuffers/protobuf-javascript/issues/127
WORKDIR /build
RUN git clone --recurse-submodules -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc
WORKDIR /build/grpc
RUN mkdir -p cmake/build; cd cmake/build; cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local ../.. && make -j 8 && make install

# Build api-interfaces
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION}
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION}

COPY . /build/api-interfaces/
WORKDIR /build/api-interfaces
RUN cmake . && cmake --build .

# Copy output to a bare container
FROM debian:bullseye-slim
COPY --from=builder /build/api-interfaces/gooseai /gooseai