Skip to content

Commit

Permalink
ci(docker): fix docker build
Browse files Browse the repository at this point in the history
fix: buiild add docker env variables

fix: build

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

chore: package lock

ci(docker): fix docker build
  • Loading branch information
Stormix committed Dec 5, 2023
1 parent da1506a commit b879203
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
25 changes: 25 additions & 0 deletions .github/workflows/deploy-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.18'
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install caprover
run: sudo npm install -g caprover

- name: Create tar
run: tar -cvf ./deploy.tar --exclude='node_modules' --exclude='.git' --exclude='.next' *

- name: Deploy
run: caprover deploy -h ${{ secrets.CAPROVER_SERVER_PROD }} -p ${{ secrets.CAPROVER_PASSWORD_PROD }} -a riftmaker -t ./deploy.tar
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ yarn-error.log*
next-env.d.ts


.env
.env
deploy.tar
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM oven/bun:latest
WORKDIR /usr/src/app

ARG THRESHOLD=${THRESHOLD}
ENV THRESHOLD=${THRESHOLD}
ARG NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
ENV NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
ARG NEXTAUTH_URL=${NEXTAUTH_URL}
ENV NEXTAUTH_URL=${NEXTAUTH_URL}
ARG DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID}
ENV DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID}
ARG DISCORD_CLIENT_SECRET=${DISCORD_CLIENT_SECRET}
ENV DISCORD_CLIENT_SECRET=${DISCORD_CLIENT_SECRET}
ARG TWITCH_CLIENT_ID=${TWITCH_CLIENT_ID}
ENV TWITCH_CLIENT_ID=${TWITCH_CLIENT_ID}
ARG TWITCH_CLIENT_SECRET=${TWITCH_CLIENT_SECRET}
ENV TWITCH_CLIENT_SECRET=${TWITCH_CLIENT_SECRET}
ARG DATABASE_URL=${DATABASE_URL}
ENV DATABASE_URL=${DATABASE_URL}
ARG NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL}
ENV NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL}

# Install nodejs using n
RUN apt-get -y update; apt-get -y install curl
ARG NODE_VERSION=18
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
&& bash n $NODE_VERSION \
&& rm n \
&& npm install -g n

COPY bun.lockb package.json prisma ./
RUN bun install

COPY . .
RUN bunx prisma generate

RUN bun run build
ENV NODE_ENV production

WORKDIR /usr/src/app/.next/standalone
EXPOSE 3000
ENTRYPOINT [ "node", "server.js" ]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next
First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```


```bash
docker build -t riftmaker-web .
```


Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
Expand Down
11 changes: 11 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

# Run Next.js build with passed arguments
next build "$@"

# Copy files only if not in a CI environment
if [ -z "$CI" ]; then
cp -r ./public ./.next/standalone/public
cp -r ./.next/static ./.next/standalone/.next/static
fi
Binary file modified bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions captain-definition
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"schemaVersion": 2,
"dockerfilePath": "./Dockerfile"
}
2 changes: 1 addition & 1 deletion env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const env = createEnv({
DISCORD_CLIENT_SECRET: z.string().min(1),
TWITCH_CLIENT_ID: z.string().min(1),
TWITCH_CLIENT_SECRET: z.string().min(1),
THRESHOLD: z.number().int().min(1).default(3),
THRESHOLD: z.coerce.number().int().min(1).default(3),
},
client: {
NEXT_PUBLIC_BASE_URL: z.string().min(1),
Expand Down
3 changes: 2 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './env.mjs';
// import './env.mjs';

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -15,6 +15,7 @@ const nextConfig = {
],
},
reactStrictMode: false,
output: 'standalone',
};

export default nextConfig;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"postinstall": "prisma generate",
"build": "bash ./build.sh",
"start": "next start",
"lint": "next lint",
"test": "vitest",
"postinstall": "prisma generate"
"test": "vitest"
},
"dependencies": {
"@auth/prisma-adapter": "^1.0.8",
Expand Down
7 changes: 4 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ datasource db {

generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x", "linux-musl","linux-musl-openssl-3.0.x"]
}

model Account {
Expand Down Expand Up @@ -43,8 +44,8 @@ model User {
accounts Account[]
sessions Session[]
isAdmin Boolean @default(false)
isBanned Boolean @default(false)
isAdmin Boolean @default(false)
isBanned Boolean @default(false)
riotId String?
role PlayerRole?
Expand All @@ -53,7 +54,7 @@ model User {
teams TeamPlayer[]
tournaments Tournament[] @relation("TournamentParticipants")
createdTournaments Tournament[] @relation("TournamentCreator")
createdTournaments Tournament[] @relation("TournamentCreator")
kickedFromTournaments Tournament[] @relation("KickedPlayers")
}

Expand Down
Empty file removed riftmaker.png:Zone.Identifier
Empty file.

0 comments on commit b879203

Please sign in to comment.