-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
8,218 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: 🚀 Deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- staging | ||
- ci/setup | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-deploy | ||
|
||
env: | ||
CI: true | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
deploy: | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22' | ||
|
||
- uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: "🔨 Install dependencies" | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: "👥 Configure AWS Credentials" | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::262732185023:role/github-action-deploy-role | ||
aws-region: eu-west-1 | ||
retry-max-attempts: 5 | ||
|
||
- name: "👥 Login to Amazon ECR" | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: "🔨 Prebuild docker dependencies" | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/arm64 | ||
push: true | ||
tags: 262732185023.dkr.ecr.eu-west-1.amazonaws.com/indexer:latest | ||
# Github actions cache | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: "🚀 SST Deploy" | ||
run: | | ||
echo "Deploying with stage: prod" | ||
pnpm sst deploy --stage prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
# use the official Bun image | ||
# see all versions at https://hub.docker.com/r/oven/bun/tags | ||
FROM oven/bun:1-debian as base | ||
# Base image is node-22 | ||
FROM node:22-slim as base | ||
|
||
# Setup pnpm | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
RUN corepack install --global [email protected] | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
COPY . . | ||
|
||
# install dependencies into temp directory | ||
# this will cache them and speed up future builds | ||
|
@@ -12,21 +18,25 @@ RUN apt-get update | |
RUN apt-get install -y \ | ||
python3 \ | ||
build-essential | ||
# Install dependencies | ||
RUN mkdir -p /temp/dev | ||
COPY package.json bun.lockb /temp/dev/ | ||
RUN cd /temp/dev && bun install --frozen-lockfile --ignore-scripts | ||
|
||
# install with --production (exclude devDependencies) | ||
# Install dependencies | ||
RUN mkdir -p /temp/prod | ||
COPY package.json bun.lockb /temp/prod/ | ||
RUN cd /temp/prod && bun install --frozen-lockfile --production --ignore-scripts | ||
COPY package.json /temp/prod/ | ||
RUN cd /temp/prod && pnpm --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod | ||
|
||
# copy production dependencies and source code into final image | ||
FROM base AS release | ||
|
||
# Set env to production | ||
ENV NODE_ENV production | ||
|
||
# copy production dependencies and source code into final image | ||
COPY . . | ||
COPY --from=install /temp/prod/node_modules node_modules | ||
|
||
# Allow node user to everything in the working directory, and switch to it | ||
#RUN chown node:node ./ | ||
#USER node | ||
|
||
# run the app | ||
USER bun | ||
EXPOSE 42069/tcp | ||
ENTRYPOINT [ "bun", "run", "start" ] | ||
ENTRYPOINT [ "pnpm", "run", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# use the official Bun image | ||
# see all versions at https://hub.docker.com/r/oven/bun/tags | ||
FROM oven/bun:1-debian as base | ||
WORKDIR /usr/src/app | ||
COPY . . | ||
|
||
# install dependencies into temp directory | ||
# this will cache them and speed up future builds | ||
FROM base AS install | ||
# install python and all the stuff required to build sqlite3 | ||
RUN apt-get update | ||
RUN apt-get install -y \ | ||
python3 \ | ||
build-essential | ||
# Install dependencies | ||
RUN mkdir -p /temp/dev | ||
COPY package.json bun.lockb /temp/dev/ | ||
# TODO: This is failing cause of better-sqlite3 dependency RAAAGH | ||
RUN cd /temp/dev && bun install --frozen-lockfile | ||
|
||
# install with --production (exclude devDependencies) | ||
RUN mkdir -p /temp/prod | ||
COPY package.json bun.lockb /temp/prod/ | ||
RUN cd /temp/prod && bun install --frozen-lockfile --production | ||
|
||
# copy production dependencies and source code into final image | ||
FROM base AS release | ||
COPY --from=install /temp/prod/node_modules node_modules | ||
|
||
# run the app | ||
USER bun | ||
EXPOSE 42069/tcp | ||
ENTRYPOINT [ "bun", "run", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,5 +26,6 @@ | |
}, | ||
"engines": { | ||
"node": ">=18.14" | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
Oops, something went wrong.