Skip to content

Commit

Permalink
Merge pull request #11 from swalker326/chore/upgrade-remix-version
Browse files Browse the repository at this point in the history
Chore/upgrade remix version
  • Loading branch information
swalker326 authored Aug 2, 2024
2 parents 74e6263 + 390bc95 commit d2607ac
Show file tree
Hide file tree
Showing 46 changed files with 9,386 additions and 33,641 deletions.
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

21 changes: 0 additions & 21 deletions .eslintrc.js

This file was deleted.

225 changes: 88 additions & 137 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@ jobs:
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 22

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
- name: 📥 Install pnpm
uses: pnpm/action-setup@v4
with:
useLockFile: false
version: 9.6.0

- name: 📥 Download deps
run: pnpm install --frozen-lockfile

- name: Setup Biome
uses: biomejs/[email protected]
with:
biome-version: 1.8.3

- name: 🔬 Lint
run: npm run lint
run: pnpm check

typecheck:
name: ʦ TypeScript
Expand All @@ -45,77 +53,86 @@ jobs:
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: 🔎 Type check
run: npm run typecheck --if-present

vitest:
name: ⚡ Vitest
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: ⚡ Run vitest
run: npm run test -- --coverage

cypress:
name: ⚫️ Cypress
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3
node-version: 22

- name: 🏄 Copy test env vars
run: cp .env.example .env

- name: ⎔ Setup node
uses: actions/setup-node@v3
- name: 📥 Install pnpm
uses: pnpm/action-setup@v4
with:
node-version: 16
version: 9.6.0

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: 🛠 Setup Database
run: npx prisma migrate reset --force
run: pnpm install --frozen-lockfile

- name: ⚙️ Build
run: npm run build

- name: 🌳 Cypress run
uses: cypress-io/github-action@v5
with:
start: npm run start:mocks
wait-on: "http://localhost:8811"
env:
PORT: "8811"
- name: 🔎 Type check
run: pnpm run typecheck

# vitest:
# name: ⚡ Vitest
# runs-on: ubuntu-latest
# steps:
# - name: 🛑 Cancel Previous Runs
# uses: styfle/[email protected]

# - name: ⬇️ Checkout repo
# uses: actions/checkout@v3

# - name: ⎔ Setup node
# uses: actions/setup-node@v3
# with:
# node-version: 16

# - name: 📥 Install pnpm
# uses: pnpm/action-setup@v2
# with:
# version: 6.32.9

# - name: 📥 Download deps
# run: pnpm install --frozen-lockfile

# - name: ⚡ Run vitest
# run: pnpm run test -- --coverage

# cypress:
# name: ⚫️ Cypress
# runs-on: ubuntu-latest
# steps:
# - name: 🛑 Cancel Previous Runs
# uses: styfle/[email protected]

# - name: ⬇️ Checkout repo
# uses: actions/checkout@v3

# - name: 🏄 Copy test env vars
# run: cp .env.example .env

# - name: ⎔ Setup node
# uses: actions/setup-node@v3
# with:
# node-version: 16

# - name: 📥 Install pnpm
# uses: pnpm/action-setup@v2
# with:
# version: 6.32.9

# - name: 📥 Download deps
# run: pnpm install --frozen-lockfile

# - name: 🛠 Setup Database
# run: pnpm prisma migrate reset --force

# - name: ⚙️ Build
# run: pnpm run build

# - name: 🌳 Cypress run
# uses: cypress-io/github-action@v5
# with:
# start: pnpm run start:mocks
# wait-on: "http://localhost:8811"
# env:
# PORT: "8811"

build:
name: 🐳 Build
Expand Down Expand Up @@ -146,69 +163,3 @@ jobs:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: 🔑 Fly Registry Auth
uses: docker/login-action@v2
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}

- name: 🐳 Docker build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck, vitest, cypress, build]
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}

steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 👀 Read app name
uses: SebRollen/[email protected]
id: app_name
with:
file: "fly.toml"
field: "app"

- name: 🚀 Deploy Staging
if: ${{ github.ref == 'refs/heads/dev' }}
uses: superfly/[email protected]
with:
args: "deploy --app ${{ steps.app_name.outputs.value }}-staging --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: 🚀 Deploy Production
if: ${{ github.ref == 'refs/heads/main' }}
uses: superfly/[email protected]
with:
args: "deploy --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ node_modules
/prisma/data.db-journal

/app/styles/tailwind.css
.DS_Store
7 changes: 0 additions & 7 deletions .prettierignore

This file was deleted.

5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///Users/shanewalker/projects/giffer/.github/workflows/deploy.yml"
}
}
79 changes: 35 additions & 44 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,64 +1,55 @@
# base node image
FROM node:16-bullseye-slim as base
# syntax = docker/dockerfile:1

# set for base and all layer that inherit from it
ENV NODE_ENV production
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=22.2.0
FROM node:${NODE_VERSION}-bullseye-slim as base

# Install openssl for Prisma
RUN apt-get update && apt-get install -y openssl sqlite3
RUN apt-get install -y ffmpeg
LABEL fly_launch_runtime="Remix"

# Install all node_modules, including dev dependencies
FROM base as deps
# Remix app lives here
WORKDIR /app

WORKDIR /myapp
# Set production environment
ENV NODE_ENV="production"

ADD package.json package-lock.json .npmrc ./
RUN npm install --production=false
# Install pnpm
ARG PNPM_VERSION=9.2.0
RUN npm install -g pnpm@$PNPM_VERSION

# Setup production node_modules
FROM base as production-deps
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y ffmpeg

WORKDIR /myapp

COPY --from=deps /myapp/node_modules /myapp/node_modules
ADD package.json package-lock.json .npmrc ./
RUN npm prune --production

# Build the app
# Throw-away build stage to reduce size of final image
FROM base as build

WORKDIR /myapp

COPY --from=deps /myapp/node_modules /myapp/node_modules

ADD prisma .
RUN npx prisma generate
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link .npmrc package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod=false

ADD . .
RUN npm run build
# Copy application code
COPY --link . .

# Finally, build the production image with minimal footprint
FROM base
# Build application
RUN pnpm run build

ENV DATABASE_URL=file:/data/sqlite.db
ENV PORT="8080"
ENV NODE_ENV="production"
# Remove development dependencies
RUN pnpm prune --prod

# add shortcut for connecting to database CLI
RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli

WORKDIR /myapp
# Final stage for app image
FROM base

COPY --from=production-deps /myapp/node_modules /myapp/node_modules
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma
# Copy built application
COPY --from=build /app /app

COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/public /myapp/public
COPY --from=build /myapp/package.json /myapp/package.json
COPY --from=build /myapp/start.sh /myapp/start.sh
COPY --from=build /myapp/prisma /myapp/prisma
RUN mkdir -p /myapp/build/tmp/input /myapp/build/tmp/output
RUN mkdir -p /app/build/server/tmp/input /app/build/server/tmp/output

ENTRYPOINT [ "./start.sh" ]
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "pnpm", "run", "start" ]
Loading

0 comments on commit d2607ac

Please sign in to comment.