-
Notifications
You must be signed in to change notification settings - Fork 527
CICD: add container build #4927
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
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
bd1ef54
actions: add container workflow
algolucky a46f191
container: use go 1.17.13
algolucky 9f44eb3
actions: setup qemu
algolucky fc4fd7c
container: consolidate EXPOSE
algolucky f45538d
actions: execute on tag push
algolucky 8f9b447
container: add --no-install-recommends
algolucky 1829653
container: use algorand user
algolucky 33f2b09
container: consolidate ENV
algolucky e7e9dd9
container: remove debug statement
algolucky c9652d3
container: consolidate RUN
algolucky 1a06547
container: move mkdir /algod/data
algolucky 84200f0
container: working algorand user
algolucky f206862
container: do not set default CHANNEL
algolucky ba9c39c
actions: use https git URL
algolucky f2b27cf
container: tidy README
algolucky 92c7041
container: consolidate ENV
algolucky 9cbe9e1
container: remove unused packages in builder
algolucky b5f331c
container: do not execute dev_install.sh
algolucky 639a72f
container: only add specific binaries
algolucky ded50c9
container: remove apt lists
algolucky 628e974
container: move COPY after user creation
algolucky ccbf5fd
container: remove curl
algolucky ab3e475
container: properly remove unecessary binaries
algolucky 6bc69c4
actions: add workflow_dispatch event trigger
algolucky 0859fe0
container: update docs
algolucky 65bce82
actions: add cache
algolucky 23b546a
container: readd curl
algolucky 6804917
container: use ubuntu:18.04 as base
algolucky acc426d
container: calculate proper BUILD_NUMBER
algolucky bc398db
container: fix fast catchup conditional
algolucky 7ca067f
scripts: allow BRANCH to be overridden
algolucky 96abc0b
add missing ca-certificates
algolucky 9d282b5
actions: use latest tag when branch is rel/stable
algolucky d49a8bb
actions: pin checkout to v3
algolucky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,57 @@ | ||
| name: container | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - master | ||
| - rel/* | ||
| - feature/* | ||
| tags: | ||
| - "*" | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Generate Container Metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v4 | ||
| with: | ||
| images: | | ||
| docker.io/${{ github.repository_owner }}/algod | ||
| tags: | | ||
| type=sha,format=long,prefix= | ||
| type=ref,event=tag | ||
| type=ref,event=branch | ||
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'rel/stable') }} | ||
|
|
||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Setup QEMU | ||
| uses: docker/setup-qemu-action@v2 | ||
|
|
||
| - name: Setup Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Build and Push | ||
| uses: docker/build-push-action@v3 | ||
| with: | ||
| context: ./ | ||
| file: ./Dockerfile | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| platforms: linux/amd64,linux/arm64 | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| build-args: | | ||
| SHA=${{ github.sha }} | ||
| URL=${{ github.server_url }}/${{ github.repository }}.git | ||
| BRANCH=${{ github.ref_name }} | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,75 +1,64 @@ | ||
| ARG GO_VERSION=1.17.5 | ||
| FROM golang:$GO_VERSION-bullseye as builder | ||
| FROM ubuntu:18.04 as builder | ||
|
|
||
| ARG CHANNEL=nightly | ||
| ARG URL= | ||
| ARG BRANCH= | ||
| ARG SHA= | ||
| ARG GO_VERSION="1.17.13" | ||
|
|
||
| ARG CHANNEL | ||
| ARG URL | ||
| ARG BRANCH | ||
| ARG SHA | ||
| ARG TARGETARCH | ||
|
|
||
| ADD https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz /go.tar.gz | ||
|
|
||
| # Basic dependencies. | ||
| ENV HOME /node | ||
| ENV DEBIAN_FRONTEND noninteractive | ||
| ENV HOME="/node" DEBIAN_FRONTEND="noninteractive" GOPATH="/node" | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get install -y \ | ||
| apt-get install -y --no-install-recommends \ | ||
| ca-certificates \ | ||
| apt-utils \ | ||
| bsdmainutils \ | ||
| curl \ | ||
| git \ | ||
| git-core \ | ||
| python3 | ||
| && rm -rf /var/lib/apt/lists/* && \ | ||
| \ | ||
| tar -C /usr/local -xzf /go.tar.gz && \ | ||
| rm -rf /go.tar.gz | ||
|
|
||
| ENV PATH="/usr/local/go/bin:${PATH}" | ||
|
|
||
| COPY ./docker/files/ /node/files | ||
| COPY ./installer/genesis /node/files/run/genesis | ||
| COPY ./cmd/updater/update.sh /node/files/build/update.sh | ||
| COPY ./installer/config.json.example /node/files/build/config.json | ||
|
|
||
| RUN find /node/files | ||
| COPY ./installer/config.json.example /node/files/run/config.json.example | ||
|
|
||
| # Install algod binaries. | ||
| RUN /node/files/build/install.sh \ | ||
| -p "/node/bin" \ | ||
| -p "${GOPATH}/bin" \ | ||
| -d "/node/data" \ | ||
| -c "${CHANNEL}" \ | ||
| -u "${URL}" \ | ||
| -b "${BRANCH}" \ | ||
| -s "${SHA}" | ||
|
|
||
| # Copy binaries into a clean image | ||
| # TODO: We don't need most of the binaries. | ||
| # Should we delete everything except goal/algod/algocfg/tealdbg? | ||
| FROM debian:bullseye-slim as final | ||
| COPY --from=builder "/node/bin/" "/node/bin" | ||
| COPY --from=builder "/node/data/" "/node/dataTemplate" | ||
| COPY --from=builder "/node/files/run" "/node/run" | ||
|
|
||
| ENV BIN_DIR="/node/bin" | ||
| ENV PATH="$BIN_DIR:${PATH}" | ||
| ENV ALGOD_PORT=8080 | ||
| ENV ALGORAND_DATA="/algod/data" | ||
| RUN mkdir -p "$ALGORAND_DATA" | ||
| WORKDIR /node/data | ||
|
algolucky marked this conversation as resolved.
|
||
| ENV PATH="/node/bin:${PATH}" ALGOD_PORT="8080" ALGORAND_DATA="/algod/data" | ||
|
|
||
| # curl is needed to lookup the fast catchup url | ||
| RUN apt-get update && apt-get install -y \ | ||
| curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # TODO: This works fine, but causes problems when mounting a volume | ||
|
algolucky marked this conversation as resolved.
|
||
| # Use algorand user instead of root | ||
| #RUN groupadd -r algorand && \ | ||
| # useradd --no-log-init -r -g algorand algorand && \ | ||
| # chown -R algorand.algorand /node && \ | ||
| # chown -R algorand.algorand /algod | ||
| #USER algorand | ||
| RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && \ | ||
| rm -rf /var/lib/apt/lists/* && \ | ||
| mkdir -p "$ALGORAND_DATA" && \ | ||
| groupadd --system algorand && \ | ||
| useradd --no-log-init --create-home --system --gid algorand algorand && \ | ||
| chown -R algorand:algorand /algod | ||
|
|
||
| # Algod REST API | ||
| EXPOSE $ALGOD_PORT | ||
| USER algorand | ||
|
|
||
| # Algod Gossip Port | ||
| EXPOSE 4160 | ||
| COPY --chown=algorand:algorand --from=builder "/node/bin/" "/node/bin/" | ||
| COPY --chown=algorand:algorand --from=builder "/node/files/run/" "/node/run/" | ||
|
|
||
| # Prometheus Metrics | ||
| EXPOSE 9100 | ||
| # Expose Algod REST API, Algod Gossip, and Prometheus Metrics ports | ||
| EXPOSE $ALGOD_PORT 4160 9100 | ||
|
|
||
| CMD ["/node/run/run.sh"] | ||
| #CMD ["/bin/bash"] | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,18 +1,21 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| if [[ -n $(git status --porcelain) ]]; then | ||
| # If the branch isn't clean, default to HEAD to match old behavior. | ||
| BRANCH="HEAD" | ||
| elif [ -z "${TRAVIS_BRANCH}" ]; then | ||
| # if there is no travis branch, set based on tag or branch | ||
| case "$(git describe --tags)" in | ||
| *"beta") BRANCH="rel/beta" ;; | ||
| *"stable") BRANCH="rel/stable" ;; | ||
| *"nightly") BRANCH="rel/nightly" ;; | ||
| *) BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
| esac | ||
| else | ||
| BRANCH="${TRAVIS_BRANCH}" | ||
| BRANCH="${BRANCH:-}" | ||
| if [ -n "$BRANCH" ]; then | ||
| if [[ -n $(git status --porcelain) ]]; then | ||
| # If the branch isn't clean, default to HEAD to match old behavior. | ||
| BRANCH="HEAD" | ||
| elif [ -z "${TRAVIS_BRANCH}" ]; then | ||
| # if there is no travis branch, set based on tag or branch | ||
| case "$(git describe --tags)" in | ||
| *"beta") BRANCH="rel/beta" ;; | ||
| *"stable") BRANCH="rel/stable" ;; | ||
| *"nightly") BRANCH="rel/nightly" ;; | ||
| *) BRANCH=$(git rev-parse --abbrev-ref HEAD) ;; | ||
| esac | ||
| else | ||
| BRANCH="${TRAVIS_BRANCH}" | ||
| fi | ||
|
algolucky marked this conversation as resolved.
|
||
| fi | ||
|
|
||
| echo "${BRANCH}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.