Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dysbulic committed Aug 14, 2024
2 parents 959ab7f + 91b4eab commit b68043e
Show file tree
Hide file tree
Showing 403 changed files with 36,740 additions and 25,318 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

83 changes: 0 additions & 83 deletions .eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ tsconfig.tsbuildinfo
# Ceramic daemon
ipfs
packages/backend/uploads/
*.key
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/iron
11 changes: 6 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"develop"
]
}
{
"githubPullRequests.ignoredPullRequestBranches": [
"develop"
],
"typescript.tsdk": "node_modules/typescript/lib"
}
7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodeLinker: node-modules

preferInteractive: true

progressBarStyle: simba

checksumBehavior: update
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ We're using the following stack:

## MetaGame

- [Website](https://metagame.wtf)
- [Wiki](https://wiki.metagame.wtf)
- [Notion](https://www.notion.so/Welcome-to-MetaGame-7e28e75f3c264c7b939eaaa2239b9c28)
- [Website](https://enter.metagame.wtf)


## Guides

Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
HASURA_GRAPHQL_DEV_MODE: ${HASURA_GRAPHQL_DEV_MODE:-false}

database:
image: postgres:12
image: postgres:16
volumes:
- database:/var/lib/postgresql/data
ports:
Expand All @@ -39,6 +39,8 @@ services:
context: .
dockerfile: ./docker/backend/Dockerfile
target: base
args:
CACHEBUST: ${CACHEBUST:-$(date +%s)}
command: yarn backend:dev
ports:
- 4000:4000
Expand Down
93 changes: 58 additions & 35 deletions docker/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,65 +1,88 @@
FROM node:20-slim as base
FROM node:20-slim AS base
WORKDIR /usr/src/app

# varying arg to prevent caching
# ARG CACHEBUST

# Install dependencies not included in the slim image
RUN apt-get update && \
apt-get install -y --no-install-recommends g++ make python3 git openssl && \
apt-get install -y --no-install-recommends --reinstall ca-certificates

# Install dependencies for dev and prod
COPY package.json .
COPY lerna.json .
COPY yarn.lock .
COPY schema.graphql .
COPY tsconfig.base.json .
COPY package.json ./
COPY lerna.json ./
COPY yarn.lock ./
COPY schema.graphql ./
COPY tsconfig.base.json ./
COPY packages/backend/*.json ./packages/backend/
COPY packages/utils/*.json ./packages/utils/
COPY packages/discord-bot/*.json ./packages/discord-bot/
# Not needed for the backend, but the --immutable flag fails w/o them
COPY packages/design-system/package.json ./packages/design-system/
COPY packages/web/package.json ./packages/web/

RUN corepack enable
RUN yarn config set nodeLinker node-modules
RUN yarn install --immutable

RUN yarn install --pure-lockfile
# RUN set -x && echo $CACHEBUST && ls -la

# Dev environment doesn't run this stage or beyond
FROM base as build
# Dev environment doesn't run beyond here
FROM base AS build

# Copy source files
COPY packages/backend ./packages/backend/
COPY packages/utils ./packages/utils/
COPY packages/discord-bot ./packages/discord-bot/
COPY packages/@types ./packages/@types/
COPY packages/backend/ ./packages/backend/
COPY packages/utils/ ./packages/utils/
COPY packages/discord-bot/ ./packages/discord-bot/
COPY packages/@types/ ./packages/@types/

# Set env vars
ARG GRAPHQL_HOST=hasura
ARG GRAPHQL_DOMAIN=onrender.com
ARG GRAPHQL_URL=https://$GRAPHQL_HOST.$GRAPHQL_DOMAIN/v1/graphql
ARG THE_GRAPH_API_TOKEN=unspecified
ARG GRAPHQL_HOST
ARG GRAPHQL_DOMAIN
ARG GRAPHQL_URL
ARG THE_GRAPH_API_TOKEN

ENV GRAPHQL_URL $GRAPHQL_URL
ENV HASURA_GRAPHQL_ADMIN_SECRET metagame_secret
ENV THE_GRAPH_API_TOKEN $THE_GRAPH_API_TOKEN
ENV GRAPHQL_URL=$GRAPHQL_URL
ENV HASURA_GRAPHQL_ADMIN_SECRET=metagame_secret
ENV THE_GRAPH_API_TOKEN=$THE_GRAPH_API_TOKEN

# Build
RUN yarn backend:build

# Delete devDependencies
RUN yarn install --pure-lockfile --production --ignore-scripts --prefer-offline
#RUN corepack enable
# RUN yarn workspaces focus @metafam/backend --production # --immutable
# RUN yarn install --immutable
# RUN yarn install --pure-lockfile --production --ignore-scripts --prefer-offline

# Create completely new stage including only necessary files
FROM node:20-slim as app
FROM node:20-slim AS app
WORKDIR /app

ARG CACHEBUST

# Copy necessary files into the stage
COPY --from=build /usr/src/app/package.json ./package.json
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/yarn.lock ./
COPY --from=build /usr/src/app/package.json ./
#COPY --from=build /usr/src/app/node_modules ./

COPY --from=build /usr/src/app/packages/backend/package.json ./packages/backend/
COPY --from=build /usr/src/app/packages/backend/dist/ ./packages/backend/dist/
#COPY --from=build /usr/src/app/packages/backend/node_modules ./packages/backend/
# RUN mkdir -p ./packages/backend/node_modules

COPY --from=build /usr/src/app/packages/utils/package.json ./packages/utils/
COPY --from=build /usr/src/app/packages/utils/dist/ ./packages/utils/dist/
#COPY --from=build /usr/src/app/packages/utils/node_modules ./packages/utils/

COPY --from=build /usr/src/app/packages/discord-bot/package.json ./packages/discord-bot/
COPY --from=build /usr/src/app/packages/discord-bot/dist/ ./packages/discord-bot/dist/

COPY --from=build /usr/src/app/packages/backend/package.json ./packages/backend/package.json
COPY --from=build /usr/src/app/packages/backend/dist ./packages/backend/dist
COPY --from=build /usr/src/app/packages/backend/node_modules ./packages/backend/node_modules
RUN corepack enable
RUN yarn config set nodeLinker node-modules
RUN yarn workspaces focus @metafam/backend --production # --immutable
RUN yarn cache clean

COPY --from=build /usr/src/app/packages/utils/package.json ./packages/utils/package.json
COPY --from=build /usr/src/app/packages/utils/dist ./packages/utils/dist
COPY --from=build /usr/src/app/packages/utils/node_modules ./packages/utils/node_modules
RUN echo $CACHEBUST && ls -la packages/*/

COPY --from=build /usr/src/app/packages/discord-bot/package.json ./packages/discord-bot/package.json
COPY --from=build /usr/src/app/packages/discord-bot/dist ./packages/discord-bot/dist

CMD ["yarn", "backend", "start"]
CMD ["yarn", "workspace", "@metafam/backend", "start"]
18 changes: 11 additions & 7 deletions docker/discord-bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-slim as base
FROM node:20-slim AS base
WORKDIR /usr/src/app

# Install dependencies not included in the slim image
Expand All @@ -15,10 +15,12 @@ COPY tsconfig.base.json .
COPY packages/discord-bot/*.json ./packages/discord-bot/
COPY packages/utils/*.json ./packages/utils/

RUN yarn install --pure-lockfile
RUN corepack enable
RUN yarn config set nodeLinker node-modules
RUN yarn install # --immutable

# Dev environment doesn't run this stage or beyond
FROM base as build
FROM base AS build

# Copy source files
COPY packages/discord-bot ./packages/discord-bot/
Expand All @@ -28,14 +30,16 @@ COPY packages/@types ./packages/@types/
# Set env vars
ARG GRAPHQL_HOST

ENV GRAPHQL_URL https://$GRAPHQL_HOST.onrender.com/v1/graphql
ENV HASURA_GRAPHQL_ADMIN_SECRET metagame_secret
ENV GRAPHQL_URL=https://$GRAPHQL_HOST.onrender.com/v1/graphql
ENV HASURA_GRAPHQL_ADMIN_SECRET=metagame_secret

# Build
RUN yarn discord-bot build

# Delete devDependencies
RUN yarn install --pure-lockfile --production --ignore-scripts --prefer-offline
RUN corepack enable
RUN yarn config set nodeLinker node-modules
RUN yarn workspaces focus @metafam/discord-bot --production # --immutable
# RUN yarn install --pure-lockfile --production --ignore-scripts --prefer-offline

# Create completely new stage including only necessary files
FROM node:20-slim as app
Expand Down
Loading

0 comments on commit b68043e

Please sign in to comment.