Skip to content
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

add docker #19

Merged
merged 1 commit into from
Feb 23, 2024
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
69 changes: 69 additions & 0 deletions .github/workflows/build-push-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
on:
push:
branches:
- main*
tags:
- 'v*'

name: Build and Publish Docker Image
jobs:
build-docker:
runs-on: ubuntu-latest
name: Build Docker Image
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-buildx-action@v2

- name: Define docker image meta data tags
id: meta
uses: docker/metadata-action@v4
with:
images: |
mayalabs/maya
ghcr.io/mayalabs/maya
tags: |
# Tag "git short sha" on all git events
type=sha,prefix=

# Tag "next" on git-push-to-main-branch events
type=raw,value=next,event=branch,enable={{is_default_branch}}

# Tag "latest" on git-tag events
type=raw,value=latest,event=tag

# Tag "$APP_VERSION" on git-push-to-branch events
type=raw,value=${{ env.APP_VERSION }},event=branch

# Tag "tag ref" on git-tag events
type=ref,event=tag

# - name: Login to Github container registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Dockerhub container registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
GITHUB_SHA=${{ github.sha }}
GO_BUILD_FLAG=${{ env.GO_BUILD_FLAG }}
tags: ${{ steps.meta.outputs.tags }}

- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short=7 ${{ github.sha }})
echo "::set-output name=short_sha::$calculatedSha"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.bin
.idea
proofs/
docs/book/
target
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Container for building Go binary.
FROM golang:1.22.0-bookworm AS builder
# Install dependencies
RUN apt-get update && apt-get install -y build-essential git
# Prep and copy source
WORKDIR /app/maya
COPY . .
# Populate GO_BUILD_FLAG with a build arg to provide an optional go build flag.
ARG GO_BUILD_FLAG
ENV GO_BUILD_FLAG=${GO_BUILD_FLAG}
RUN echo "Building with GO_BUILD_FLAG='${GO_BUILD_FLAG}'"
# Build with Go module and Go build caches.
RUN \
--mount=type=cache,target=/go/pkg \
--mount=type=cache,target=/root/.cache/go-build \
go build -o maya "${GO_BUILD_FLAG}" .
RUN echo "Built maya version=$(./maya --version)"

# Copy final binary into light stage.
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates wget
ARG GITHUB_SHA=local
ENV GITHUB_SHA=${GITHUB_SHA}
COPY --from=builder /app/maya/maya /usr/local/bin/
# Don't run container as root
ENV USER=maya
ENV UID=1000
ENV GID=1000
RUN addgroup --gid "$GID" "$USER"
RUN adduser \
--disabled-password \
--gecos "maya" \
--home "/opt/$USER" \
--ingroup "$USER" \
--no-create-home \
--uid "$UID" \
"$USER"
RUN chown maya /usr/local/bin/maya
RUN chmod u+x /usr/local/bin/maya
WORKDIR "/opt/$USER"
USER maya
ENTRYPOINT ["/usr/local/bin/maya"]
CMD ["run"]
# Used by GitHub to associate container with repo.
LABEL org.opencontainers.image.source="https://github.com/obolnetwork/maya"
LABEL org.opencontainers.image.title="maya"
LABEL org.opencontainers.image.description="Proof of Stake Ethereum Distributed Validator Client"
LABEL org.opencontainers.image.licenses="GPL v3"
LABEL org.opencontainers.image.documentation="https://github.com/ObolNetwork/maya/tree/main/docs"
1 change: 0 additions & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ title = "Maya Docs"
description = "A book on all things maya"

[output.html]
theme = "book/theme"
git-repository-url = "https://github.com/LabsMaya/maya-zk-benchmarks"
default-theme = "ayu"
no-section-label = true
Expand Down
4 changes: 4 additions & 0 deletions book/introduction.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Introduction

[Maya Labs](https://mayalabs.tech/) is an R&D company that builds tools to ensure the authenticity of digital media content.

[//]: # (![](./logo.png))

<img src="./logo.png" width="300" height="300">
Binary file added book/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading