-
Notifications
You must be signed in to change notification settings - Fork 47
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
F/docker #83
Merged
F/docker #83
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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,40 +1,65 @@ | ||
name: docker | ||
|
||
name: Docker Release | ||
defaults: | ||
run: | ||
shell: bash -leo pipefail {0} | ||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
tags: | ||
- 'v*' | ||
- v** | ||
env: | ||
ECR_ENABLED: false | ||
ECR_REPO: public.ecr.aws/l9h3g6c6/peggo | ||
GHCR_ENABLED: true | ||
GHCR_REPO: ghcr.io/InjectiveLabs/peggo | ||
|
||
jobs: | ||
docker: | ||
docker-release: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
steps: | ||
- name: Checkout peggo | ||
uses: actions/checkout@master | ||
with: | ||
repository: InjectiveLabs/peggo | ||
fetch-depth: 0 | ||
ref: ${{ github.ref_name }} | ||
token: ${{ secrets.GH_TOKEN }} | ||
path: ./peggo | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=raw,value=latest | ||
type=semver,pattern=v{{version}} | ||
- name: Log-in to ghcr.io | ||
if: env.GHCR_ENABLED == 'true' | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
- name: Login to Public ECR | ||
if: env.ECR_ENABLED == 'true' | ||
uses: docker/login-action@v2 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
registry: public.ecr.aws | ||
username: ${{ secrets.AWS_KEY }} | ||
password: ${{ secrets.AWS_SECRET }} | ||
env: | ||
AWS_REGION: us-east-1 | ||
|
||
- name: Build image and push | ||
run: | | ||
cd peggo/ | ||
TAG=$(echo ${GITHUB_REF#refs/heads/} | cut -d '/' -f 2) | ||
echo $TAG | ||
[[ $ECR_ENABLED == "false" ]] || docker buildx build --tag $ECR_REPO:$TAG --platform linux/amd64,linux/arm64 --push . | ||
[[ $GHCR_ENABLED == "false" ]] || docker buildx build --tag $GHCR_REPO:$TAG --platform linux/amd64,linux/arm64 --push . | ||
|
||
- name: NONROOT Build image and push | ||
run: | | ||
cd peggo/ | ||
TAG=$(echo ${GITHUB_REF#refs/heads/} | cut -d '/' -f 2)-nonroot | ||
echo $TAG | ||
[[ $ECR_ENABLED == "false" ]] || docker buildx build -f Dockerfile.nonroot --tag $ECR_REPO:$TAG --platform linux/amd64,linux/arm64 --push . | ||
[[ $GHCR_ENABLED == "false" ]] || docker buildx build -f Dockerfile.nonroot --tag $GHCR_REPO:$TAG --platform linux/amd64,linux/arm64 --push . |
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,35 @@ | ||
#install packages for build layer | ||
FROM golang:1.19-alpine as builder | ||
RUN apk add --no-cache git gcc make perl jq libc-dev linux-headers | ||
|
||
#build binary | ||
WORKDIR /src | ||
COPY . . | ||
RUN go mod download | ||
|
||
#install binary | ||
RUN make install | ||
|
||
#build main container | ||
FROM alpine:latest | ||
|
||
# Add the "injective" non-root user and group | ||
RUN addgroup -S injective && adduser -S -G injective injective | ||
|
||
# Install dependencies | ||
RUN apk add --update --no-cache ca-certificates curl | ||
|
||
# Copy the peggo binary | ||
COPY --from=builder /go/bin/* /usr/local/bin/ | ||
|
||
# Set ownership and permissions | ||
RUN chown -R injective:injective /usr/local/bin | ||
|
||
# Configure container | ||
USER injective | ||
VOLUME /apps/data | ||
WORKDIR /home/injective/.injectived/peggo | ||
|
||
# Default command | ||
CMD peggo orchestrator | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be the other way around? ECR enabled but GHCR disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw that we have a GHCR for this so I flicked it. Should I revert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can push on GHCR too but on ECR for sure, everything is on ECR including peggo and testnet validators get images from there too.
We can consider a move to GHCR later for all images.