-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat(docker): add dockerfile and workflow #348
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3fa5777
feat(docker): add dockerfile and workflow
wo-o bcdff53
feat(docker): add dockerfile and workflow
wo-o 126334f
Merge branch 'main' into feat/dockerizing
AndyBoWu 6cf47c0
feat(docker): change expose port
wo-o 498a76f
Merge branch 'main' into feat/dockerizing
wo-o 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build and Push to Docker Hub | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
# Build and upload the geth binary | ||
build_and_push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 | ||
|
||
- name: Set build arguments | ||
run: | | ||
echo "REPOSITORY_URI=${{ vars.REPOSITORY_URI }}" >> $GITHUB_ENV | ||
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV | ||
echo "BUILDNUM=${{ github.run_number }}" >> $GITHUB_ENV | ||
|
||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Dockerize the geth and bootnode binary | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
run: | | ||
docker buildx create --use | ||
docker buildx build \ | ||
--platform linux/amd64,linux/arm64,linux/arm64/v8 \ | ||
--build-arg BUILDNUM=$BUILDNUM \ | ||
--build-arg COMMIT=$COMMIT \ | ||
--build-arg VERSION=$VERSION \ | ||
-t $REPOSITORY_URI:latest \ | ||
-t $REPOSITORY_URI:$COMMIT \ | ||
-t $REPOSITORY_URI:$VERSION \ | ||
--cache-from=type=local,src=/tmp/.buildx-cache \ | ||
--cache-to=type=local,dest=/tmp/.buildx-cache \ | ||
--push \ | ||
-f ./Dockerfile \ | ||
. |
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,37 @@ | ||
# Support setting various labels on the final image | ||
ARG COMMIT="" | ||
ARG VERSION="" | ||
ARG BUILDNUM="" | ||
|
||
# Build Geth in a stock Go builder container | ||
FROM golang:1.22-alpine as builder | ||
|
||
# Set the Current Working Directory inside the container | ||
WORKDIR /story | ||
|
||
# Copy go.mod and go.sum files | ||
COPY go.mod go.sum ./ | ||
|
||
# Download all dependencies. Dependencies are cached if the go.mod and go.sum files are not changed | ||
RUN go mod download | ||
|
||
ADD . /story/ | ||
RUN go build -o story ./client | ||
|
||
# Pull Geth into a second stage deploy alpine container | ||
FROM alpine:latest | ||
|
||
RUN apk add --no-cache ca-certificates | ||
COPY --from=builder /story/story /usr/local/bin/ | ||
|
||
EXPOSE 8545 8546 30303 30303/udp | ||
|
||
WORKDIR /root/.story/story | ||
ENTRYPOINT ["/bin/sh", "-c", "story init --network $NETWORK && exec story run \"$@\"", "--"] | ||
|
||
# Add some metadata labels to help programmatic image consumption | ||
ARG COMMIT="" | ||
ARG VERSION="" | ||
ARG BUILDNUM="" | ||
|
||
LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM" network="$NETWORK" |
Oops, something went wrong.
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.
these ports seem to be the port of
geth
? maybe we need to expose the ports used bystory
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.
It could be. On CL side, 26656 for p2p and 26657 for rpc. In addition, 1317 (by default) for API should be opened for providing API service.
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.
I changed expose port. Thanks!