Skip to content

Commit

Permalink
docker-update
Browse files Browse the repository at this point in the history
  • Loading branch information
alankritdabral committed Mar 14, 2024
1 parent b192cad commit 8056c3a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 41 deletions.
80 changes: 42 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -433,44 +433,48 @@ jobs:
APP_VERSION: ${{needs.draft_release.outputs.create_release_name }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

build-and-push-image:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/tc-server
needs: [draft_release, release]
if: (startsWith(github.event.head_commit.message, 'feat') || startsWith(github.event.head_commit.message, 'fix')) && (github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout Repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUBTOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract Metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and Push the Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-image:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/tc-server
needs: [draft_release, release]
if: (startsWith(github.event.head_commit.message, 'feat') || startsWith(github.event.head_commit.message, 'fix')) && (github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUBTOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract Metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step extracts the version from the Git tag
- name: Extract Version from Git Tag
id: extract_version
run: echo "::set-output name=VERSION::$(echo ${{ github.ref }} | cut -d '/' -f 3)"
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and Push the Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}, latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.extract_version.outputs.VERSION }}
labels: ${{ steps.meta.outputs.labels }}


homebrew-release:
name: Homebrew Release
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
FROM rust:slim-buster AS builder

WORKDIR /prod

# Copy manifests and the graphql file
COPY Cargo.lock Cargo.toml examples/jsonplaceholder.graphql docker.sh ./

Expand All @@ -20,8 +21,6 @@ RUN apt-get update && apt-get install -y pkg-config libssl-dev python g++ git ma
# Copy the rest of the source code
COPY . .

RUN chmod +x docker.sh && ./docker.sh

# Compile the project
RUN RUST_BACKTRACE=1 cargo build --release

Expand All @@ -32,5 +31,9 @@ FROM fedora:41 AS runner
COPY --from=builder /prod/target/release/tailcall /bin
COPY --from=builder /prod/jsonplaceholder.graphql /jsonplaceholder.graphql

# Install tailcall globally (latest version)
RUN docker pull ghcr.io/tailcallhq/tailcall/tc-server
RUN docker run -p 8080:8080 -p 8081:8081 ghcr.io/tailcallhq/tailcall/tc-server

ENV TAILCALL_LOG_LEVEL=error
CMD ["/bin/tailcall", "start", "jsonplaceholder.graphql"]
CMD ["/bin/tailcall", "start", "jsonplaceholder.graphql"]

0 comments on commit 8056c3a

Please sign in to comment.