Skip to content

Instantly share code, notes, and snippets.

@TheRealFlyingCoder
Last active February 14, 2025 00:19
Show Gist options
  • Save TheRealFlyingCoder/80556cb29463ae3d2b424f61e8e5830d to your computer and use it in GitHub Desktop.
Save TheRealFlyingCoder/80556cb29463ae3d2b424f61e8e5830d to your computer and use it in GitHub Desktop.

Revisions

  1. TheRealFlyingCoder revised this gist Jan 18, 2023. 3 changed files with 3 additions and 7 deletions.
    2 changes: 1 addition & 1 deletion Cloud Run & Remix
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ Step 2: Allow all traffic in the /triggers tab
    Cloud Build:
    Step 1: Set up a Cloud Build trigger on your repo
    Step 2: Point the configuration to "cloud build configuration file" at the root of your project
    Step 3: Add _REMIX_TOKEN to the substitution variables (so you can keep it safe) you should also have:
    Step 3: Add the following to the substitution variables (so you can keep it safe):
    _SERVICE_NAME: your service ID from Cloud run above
    _DEPLOY_REGION: where you want it deployed to

    6 changes: 2 additions & 4 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,5 @@
    # # base node image
    FROM node:16-bullseye-slim as base
    ARG REMIX_TOKEN
    ENV REMIX_TOKEN=${REMIX_TOKEN}

    # # Build the dev image
    FROM base as build
    @@ -16,15 +14,15 @@ FROM base as production-deps
    RUN mkdir /app/
    WORKDIR /app/
    COPY --from=build /app/node_modules /app/node_modules
    ADD package.json package-lock.json .npmrc /app/
    ADD package.json package-lock.json /app/
    RUN npm prune --production

    # Pull out the build files and do a production install
    FROM base
    ENV NODE_ENV=production
    RUN mkdir /app/
    WORKDIR /app/
    ADD package.json package-lock.json .npmrc /app/
    ADD package.json package-lock.json /app/
    COPY --from=build /app/public /app/public
    COPY --from=build /app/server /app/server
    COPY --from=production-deps /app/node_modules /app/node_modules
    2 changes: 0 additions & 2 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,6 @@ steps:
    "build",
    "-t",
    "gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA",
    "--build-arg",
    "REMIX_TOKEN=$_REMIX_TOKEN",
    "."
    ]
    - name: 'gcr.io/cloud-builders/docker'
  2. TheRealFlyingCoder renamed this gist Sep 27, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. TheRealFlyingCoder created this gist Sep 27, 2021.
    31 changes: 31 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # # base node image
    FROM node:16-bullseye-slim as base
    ARG REMIX_TOKEN
    ENV REMIX_TOKEN=${REMIX_TOKEN}

    # # Build the dev image
    FROM base as build
    RUN mkdir /app/
    WORKDIR /app/
    COPY . /app
    RUN npm install
    RUN npm run build

    # # Get the production modules
    FROM base as production-deps
    RUN mkdir /app/
    WORKDIR /app/
    COPY --from=build /app/node_modules /app/node_modules
    ADD package.json package-lock.json .npmrc /app/
    RUN npm prune --production

    # Pull out the build files and do a production install
    FROM base
    ENV NODE_ENV=production
    RUN mkdir /app/
    WORKDIR /app/
    ADD package.json package-lock.json .npmrc /app/
    COPY --from=build /app/public /app/public
    COPY --from=build /app/server /app/server
    COPY --from=production-deps /app/node_modules /app/node_modules
    CMD ["node", "server/index.js"]
    20 changes: 20 additions & 0 deletions Remix & Cloud Run
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    So you want to set up remix in cloud run huh? It's pretty simple but i'm going to assume you can figure out most of the GCP UI on your own.

    Cloud Run:
    Step 1: Create a new service and take note of the service ID
    Step 2: Allow all traffic in the /triggers tab

    Cloud Build:
    Step 1: Set up a Cloud Build trigger on your repo
    Step 2: Point the configuration to "cloud build configuration file" at the root of your project
    Step 3: Add _REMIX_TOKEN to the substitution variables (so you can keep it safe) you should also have:
    _SERVICE_NAME: your service ID from Cloud run above
    _DEPLOY_REGION: where you want it deployed to

    Repo:
    Step 1: Add the cloudbuild.yaml to your project root
    Step 2: Add the Dockerfile to your project root
    Note: The Dockerfile will change depending on which Remix version you are using
    so try to understand what it does so you can make project specific changes
    Step 3: Update your firebase.json to rewrite all routes to the cloud build service
    Step 4: Push up the changes and watch to see cloud build successfully ran.
    21 changes: 21 additions & 0 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@

    steps:
    # Build the container image
    - name: "gcr.io/cloud-builders/docker"
    args:
    [
    "build",
    "-t",
    "gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA",
    "--build-arg",
    "REMIX_TOKEN=$_REMIX_TOKEN",
    "."
    ]
    - name: 'gcr.io/cloud-builders/docker'
    args: ['push', 'gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA']
    - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    entrypoint: gcloud
    args: ['run', 'deploy', '$_SERVICE_NAME', '--image', 'gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA', '--region', '$_DEPLOY_REGION']
    images: [
    "gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA"
    ]
    19 changes: 19 additions & 0 deletions firebase.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    "hosting": [
    {
    "site": "my-site",
    "public": "public",
    "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
    ],
    "rewrites": [
    {
    "source": "**",
    "run": {
    "serviceId": "my-service-id"
    }
    }
    ]
    }
    ],