-
Notifications
You must be signed in to change notification settings - Fork 26
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
Docker build and publishing #30
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22174e9
Fix .env.localhost graphql URL
tuler faa24aa
Enable standalone build and allow customization of basePath
tuler e936b8d
Not use value from .env during graphql codegen
tuler 9a3f86b
Docker build
tuler b86940a
Sunodo build configuration
tuler 6f91857
Docker compose test
tuler c5947a1
CI docker build
tuler 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,10 @@ | ||
.dockerignore | ||
.git | ||
.next | ||
.turbo | ||
dist | ||
docker | ||
Dockerfile | ||
node_modules | ||
npm-debug.log | ||
README.md |
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,58 @@ | ||
name: Docker | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
pull_request: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
name=ghcr.io/cartesi/rollups-explorer | ||
name=docker.io/cartesi/rollups-explorer,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: depot/setup-action@v1 | ||
|
||
- name: Build and push docker image | ||
id: docker_build | ||
uses: depot/bake-action@v1 | ||
with: | ||
files: | | ||
./docker-bake.hcl | ||
${{ steps.docker_meta.outputs.bake-file }} | ||
./docker-bake.platforms.hcl | ||
push: true | ||
project: ${{ vars.DEPOT_PROJECT }} |
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
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,2 +1,2 @@ | ||
NEXT_PUBLIC_CHAIN_ID=31337 | ||
NEXT_PUBLIC_EXPLORER_API_URL="http://127.0.0.1:8545" | ||
NEXT_PUBLIC_EXPLORER_API_URL="http://127.0.0.1:4350/graphql" |
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,3 @@ | ||
NEXT_PUBLIC_CHAIN_ID=31337 | ||
NEXT_PUBLIC_EXPLORER_API_URL="http://squid_api:4350/graphql" | ||
BASE_PATH="/explorer" |
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
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
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,11 @@ | ||
target "docker-metadata-action" {} | ||
target "docker-platforms" {} | ||
|
||
target "default" { | ||
inherits = ["docker-metadata-action", "docker-platforms"] | ||
dockerfile = "docker/Dockerfile" | ||
context = "." | ||
args = { | ||
"ENVIRONMENT" = "sunodo" | ||
brunomenezes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
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,3 @@ | ||
target "default" { | ||
tags = ["cartesi/rollups-explorer:devel"] | ||
} |
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,6 @@ | ||
target "docker-platforms" { | ||
platforms = [ | ||
"linux/amd64", | ||
"linux/arm64" | ||
] | ||
} |
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,53 @@ | ||
FROM node:20-alpine as base | ||
|
||
FROM base as builder | ||
RUN apk add --no-cache libc6-compat | ||
RUN apk update | ||
|
||
WORKDIR /app | ||
RUN yarn global add turbo | ||
COPY . . | ||
RUN turbo prune --scope=web --docker | ||
|
||
# Add lockfile and package.json's of isolated subworkspace | ||
FROM base AS installer | ||
RUN apk add --no-cache libc6-compat | ||
RUN apk update | ||
WORKDIR /app | ||
|
||
# First install the dependencies (as they change less often) | ||
COPY .gitignore .gitignore | ||
COPY --from=builder /app/out/json/ . | ||
COPY --from=builder /app/out/yarn.lock ./yarn.lock | ||
RUN yarn install | ||
|
||
# Build the project | ||
COPY --from=builder /app/out/full/ . | ||
ARG ENVIRONMENT=localhost | ||
COPY --from=builder /app/out/full/apps/web/.env.${ENVIRONMENT} ./apps/web/.env | ||
RUN yarn build --filter=web | ||
|
||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
|
||
# Don't run production as root | ||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
#COPY --from=installer /app/apps/web/public ./public | ||
COPY --from=installer /app/apps/web/next.config.js . | ||
COPY --from=installer /app/apps/web/package.json . | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ | ||
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static | ||
|
||
USER nextjs | ||
EXPOSE 3000 | ||
ENV PORT 3000 | ||
ENV HOSTNAME 0.0.0.0 | ||
|
||
CMD ["node", "apps/web/server.js"] |
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,14 @@ | ||
version: "3.9" | ||
|
||
services: | ||
proxy: | ||
image: traefik:v2.10 | ||
ports: | ||
- 8080:8080 | ||
- 8088:8088 | ||
volumes: | ||
- ./traefik:/etc/traefik | ||
explorer: | ||
image: cartesi/rollups-explorer:devel | ||
expose: | ||
- 3000 |
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,10 @@ | ||
http: | ||
routers: | ||
explorer: | ||
rule: "PathPrefix(`/explorer`)" | ||
service: explorer | ||
services: | ||
explorer: | ||
loadBalancer: | ||
servers: | ||
- url: "http://explorer:3000" |
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,11 @@ | ||
api: | ||
dashboard: true | ||
insecure: true | ||
entryPoints: | ||
web: | ||
address: ":8080" | ||
traefik: | ||
address: ":8088" | ||
providers: | ||
file: | ||
directory: /etc/traefik/conf.d |
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
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.
@tuler, Is it not better to get from the environment variable instead of hardcoded?
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.
the problem of using the environment is that often we want to build for localhost but the localhost environment is not necessarily running during the build
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.
But then you can set up that build to whatever URL you want to work with. Because the environments (sepolia/mainnet) may be in parity now, but that is not guaranteed, and the testnet is more likely to have new graphQL updates that would cause build problems on Vercel, for example. I think we don't have this defined here on GitHub action variables, but I would setup to use Sepolia endpoints.
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.
So maybe we should separate the
NEXT_PUBLIC_EXPLORER_API_URL
variable from the variable used by the codegen?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.
Yeah. For now, it shouldn't be a problem and should not be a blocker to proceed with Sunodo's developments. But we will need to improve that part for this code generator to support multiple situations, e.g. Our own Vercel deployments, docker image generation for external use, etc.