diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fa489689c..e7509de039 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -437,6 +437,7 @@ jobs: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }}/tc-server + APP_VERSION: ${{ needs.draft_release.outputs.create_release_name }} # Ensure APP_VERSION is set correctly 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 @@ -461,6 +462,9 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ env.APP_VERSION }} + type=raw,value=latest,enable=${{ endsWith(env.APP_VERSION, '-SNAPSHOT') == false }} # 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. diff --git a/Dockerfile b/Dockerfile index 7583940317..c9bc10623c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,4 @@ -# Builder stage -FROM rust:slim-buster AS builder - -WORKDIR /prod -# Copy manifests and the graphql file -COPY Cargo.lock Cargo.toml examples/jsonplaceholder.graphql docker.sh ./ - -ADD https://github.com/sclevine/yj/releases/download/v5.1.0/yj-linux-amd64 /usr/local/bin/yj -ADD https://github.com/mikefarah/yq/releases/download/v4.40.5/yq_linux_amd64 /usr/local/bin/yq -RUN chmod +x /usr/local/bin/yj /usr/local/bin/yq -RUN chmod +x docker.sh && ./docker.sh - -# This is the trick to speed up the building process. -RUN mkdir .cargo \ - && cargo vendor > .cargo/config - -# Install required system dependencies and cleanup in the same layer -RUN apt-get update && apt-get install -y pkg-config libssl-dev python g++ git make libglib2.0-dev && apt-get clean && rm -rf /var/lib/apt/lists/* - -# 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 - -# Runner stage -FROM fedora:41 AS runner - -# Copy necessary files from the builder stage -COPY --from=builder /prod/target/release/tailcall /bin -COPY --from=builder /prod/jsonplaceholder.graphql /jsonplaceholder.graphql - -ENV TAILCALL_LOG_LEVEL=error -CMD ["/bin/tailcall", "start", "jsonplaceholder.graphql"] +FROM ubuntu:latest +RUN apt-get update && apt-get install -y curl +RUN curl -sSL https://raw.githubusercontent.com/tailcallhq/tailcall/master/install.sh | bash -s -- v0.55.0 +ENV PATH="${PATH}:~/.tailcall/bin" diff --git a/src/cli/tc.rs b/src/cli/tc.rs index fb2311b9a8..32d3a61e2b 100644 --- a/src/cli/tc.rs +++ b/src/cli/tc.rs @@ -17,6 +17,7 @@ use crate::print_schema; const FILE_NAME: &str = ".tailcallrc.graphql"; const YML_FILE_NAME: &str = ".graphqlrc.yml"; +const JSON_FILE_NAME: &str = ".tailcallrc.schema.json"; pub async fn run() -> Result<()> { let cli = Cli::parse(); @@ -73,8 +74,10 @@ pub async fn init(folder_path: &str) -> Result<()> { } let tailcallrc = include_str!("../../generated/.tailcallrc.graphql"); + let tailcallrc_json: &str = include_str!("../../generated/.tailcallrc.schema.json"); let file_path = Path::new(folder_path).join(FILE_NAME); + let json_file_path = Path::new(folder_path).join(JSON_FILE_NAME); let yml_file_path = Path::new(folder_path).join(YML_FILE_NAME); let tailcall_exists = fs::metadata(&file_path).is_ok(); @@ -87,9 +90,11 @@ pub async fn init(folder_path: &str) -> Result<()> { if confirm { fs::write(&file_path, tailcallrc.as_bytes())?; + fs::write(&json_file_path, tailcallrc_json.as_bytes())?; } } else { fs::write(&file_path, tailcallrc.as_bytes())?; + fs::write(&json_file_path, tailcallrc_json.as_bytes())?; } let yml_exists = fs::metadata(&yml_file_path).is_ok();