Skip to content

Commit

Permalink
fix deployment ci (#37)
Browse files Browse the repository at this point in the history
* fix deploy workflow

* move MAGICSWAPV2_API_URL to ENV

* pass build arg

* move arg def

* test print MAGICSWAPV2_API_URL

* try diff syntax

* fix deploy command

* try deploying without pruning dev deps

* simplify healthcheck

* fix isbot import

* revert cachified

* remove test branch
  • Loading branch information
alecananian authored May 29, 2024
1 parent d97f3a5 commit c4137d3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/app/generated.ts
app/generated.ts
build/
tailwind.config.js
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
- name: Set up flyctl
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy
run: flyctl deploy --config ./apps/login/fly.toml --app ${{ vars.APP_NAME }} --remote-only --build-secret dotenv="${{ secrets.ENV }}"
run: flyctl deploy --config ./fly.toml --app ${{ vars.APP_NAME }} --remote-only --build-secret dotenv="${{ secrets.ENV }}" --build-arg MAGICSWAPV2_API_URL=${{ vars.MAGICSWAPV2_API_URL }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ ENV NODE_ENV="production"
# Throw-away build stage to reduce size of final image
FROM base as build

# Set environment variables
ARG MAGICSWAPV2_API_URL
ENV MAGICSWAPV2_API_URL=$MAGICSWAPV2_API_URL

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y build-essential pkg-config python-is-python3
Expand All @@ -38,9 +42,6 @@ RUN --mount=type=secret,id=dotenv,dst=env \
tr ' ' '\n' < env > .env && \
npm run build

# Remove development dependencies
RUN npm prune --omit=dev

# Final stage for app image
FROM base

Expand Down
2 changes: 1 addition & 1 deletion app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { createReadableStreamFromReadable } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import {isbot} from "isbot";
import { PassThrough } from "node:stream";
import { renderToPipeableStream } from "react-dom/server";

Expand Down
19 changes: 1 addition & 18 deletions app/routes/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
// https://fly.io/docs/reference/configuration/#services-http_checks
import type { LoaderFunctionArgs } from "@remix-run/node";

export const loader = async ({ request }: LoaderFunctionArgs) => {
const host =
request.headers.get("X-Forwarded-Host") ?? request.headers.get("host");

try {
const url = new URL("/", `http://${host}`);
await fetch(url.toString(), { method: "HEAD" }).then((r) => {
if (!r.ok) return Promise.reject(r);
});
return new Response("OK");
} catch (error: unknown) {
console.log("healthcheck ❌", { error });
return new Response("ERROR", { status: 500 });
}
};
export const loader = () => new Response("OK");
21 changes: 10 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@tanstack/react-query": "^5.28.6",
"@treasure-project/branding": "^1.2.0",
"buffer-polyfill": "npm:buffer@^6.0.3",
"cachified": "^4.0.0",
"cachified": "^3.4.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"connectkit": "^1.7.2",
Expand Down

0 comments on commit c4137d3

Please sign in to comment.