Skip to content

Commit

Permalink
Build and Push Fuel-Core Docker Image (FuelLabs#110)
Browse files Browse the repository at this point in the history
* Updating docker build&publish based on master only
  • Loading branch information
rfuelsh authored Jan 13, 2022
1 parent 1c2aa03 commit daa4d2c
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 6 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
REGISTRY: ghcr.io

jobs:
build:
Expand Down Expand Up @@ -88,3 +89,89 @@ jobs:
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

build-publish-master-image:
needs: build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/fuellabs/fuel-core
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
flavor: |
latest=${{ github.ref == 'refs/heads/master' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the ghcr.io registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push the image to ghcr.io
uses: docker/build-push-action@v2
with:
context: .
file: deployment/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

build-publish-release-image:
# Build & Publish Docker Image Per Fuel-Core Release
needs: publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/fuellabs/fuel-core
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the ghcr.io registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push the image to ghcr.io
uses: docker/build-push-action@v2
with:
context: .
file: deployment/Dockerfile
push: true
tags: ${{ github.ref_name }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
5 changes: 2 additions & 3 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ RUN apt-get update && \
clang \
libclang-dev \
libssl-dev \
&& mkdir -p ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /build/

COPY . .

RUN --mount=type=ssh cargo build --release
RUN cargo build --release

# Stage 2: Run
FROM ubuntu:20.04 as run
Expand Down Expand Up @@ -47,4 +46,4 @@ COPY --from=builder /build/target/release/fuel-core.d .
# hadolint ignore=DL3025
CMD exec ./fuel-core --ip ${IP} --port ${PORT} --db-path ${DB_PATH}

EXPOSE ${PORT}
EXPOSE ${PORT}
8 changes: 5 additions & 3 deletions deployment/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: "3"
version: "3.9"

services:
api:
build: .
fuel-core:
build:
context: .
dockerfile: deployment/Dockerfile
image: fuel-core
ports:
- "4000:4000"
Expand Down

0 comments on commit daa4d2c

Please sign in to comment.