Skip to content

Commit

Permalink
try ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Salka1988 committed Mar 15, 2024
1 parent 5063e76 commit 8fb2d3e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .github/actions/docker-publish/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ runs:
type=ref,event=branch
type=sha,prefix=
type=semver,pattern={{raw}}
flavor: |
latest=${{ github.ref == 'refs/heads/master' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -70,6 +72,7 @@ runs:
id: publish
with:
context: ${{ inputs.context }}
platforms: linux/amd64, linux/arm64
file: ${{ inputs.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down
42 changes: 27 additions & 15 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build ad publish Docker image
name: Build and publish Docker image

on:
push:
Expand All @@ -10,24 +10,36 @@ on:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build-and-publish-image:
runs-on: buildjet-4vcpu-ubuntu-2204
if: |
(github.event_name == 'release' && github.event.action == 'published') ||
github.ref == 'refs/heads/main' || github.ref == 'refs/heads/salka1988/add_ci' || github.event_name == 'pull_request'
github.event_name == 'release' && github.event.action == 'published' ||
github.ref == 'refs/heads/main' || github.ref == 'refs/heads/salka1988/add_ci' ||
github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Rust dependencies
uses: actions/cache@v2
with:
path: /usr/local/cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('fuel-graph-node/**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build and push Fuel Graph Node Image
uses: ./.github/actions/docker-publish
id: publish
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/fuellabs/fuel-graph-node
dockerfile: fuel-graph-node/docker/Dockerfile
context: .
file: fuel-graph-node/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/fuellabs/fuel-graph-node:latest
ghcr.io/fuellabs/fuel-graph-node:${{ github.sha }}
48 changes: 48 additions & 0 deletions fuel-graph-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Stage 1: Build dependencies
FROM rust:bullseye as dependencies

WORKDIR /app

# Copy only the dependency manifest files
COPY fuel-graph-node/Cargo.toml fuel-graph-node/Cargo.lock ./

# Build dependencies separately to leverage Docker cache
RUN mkdir src && \
echo "fn main() {println!(\"dummy\")}" > src/main.rs && \
cargo build --release

# Stage 2: Build the application
FROM dependencies as builder

# Copy the source code
COPY fuel-graph-node /app/fuel-graph-node

# Build the application
RUN cd /app/fuel-graph-node && cargo build --release

# Stage 3: Create the final image
FROM debian:bullseye-slim as final

# Copy the built binary from the builder stage
COPY --from=builder /app/fuel-graph-node/target/release/graph-node /app/graph-node

# Set environment variables and expose ports
ENV RUST_LOG ""
ENV GRAPH_LOG ""
ENV EARLY_LOG_CHUNK_SIZE ""
ENV postgres_host ""
ENV postgres_user ""
ENV postgres_pass ""
ENV postgres_db ""
ENV postgres_args "sslmode=prefer"
ENV ipfs ""
ENV ethereum ""
ENV node_role "combined-node"
ENV node_id "default"
ENV ethereum_polling_interval ""
ENV GRAPH_NODE_CONFIG ""
ENV disable_core_dumps ""
EXPOSE 8000 8001 8020 8030

# Set the command to run the application
CMD ["/app/graph-node"]
2 changes: 1 addition & 1 deletion fuel-graph-node/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ ADD docker/wait_for docker/start /usr/local/bin/
COPY --from=graph-node-build /usr/local/bin/graph-node /usr/local/bin/graphman /usr/local/bin/
COPY --from=graph-node-build /etc/image-info /etc/image-info
COPY --from=envsubst /go/bin/envsubst /usr/local/bin/
#COPY docker/Dockerfile /Dockerfile
COPY docker/Dockerfile /Dockerfile
CMD ["start"]

0 comments on commit 8fb2d3e

Please sign in to comment.