This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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
13 changed files
with
154 additions
and
108 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,39 @@ | ||
version: '3' | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
container_name: storagebox-postgres | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: 123 | ||
POSTGRES_DB: postgres | ||
ports: | ||
- "5432:5432" | ||
|
||
redis: | ||
image: redis:latest | ||
container_name: storagebox-redis | ||
ports: | ||
- "6379:6379" | ||
|
||
server: | ||
container_name: storagebox-server | ||
build: | ||
context: ./server | ||
dockerfile: Dockerfile | ||
ports: | ||
- "4000:4000" | ||
depends_on: | ||
- postgres | ||
- redis | ||
|
||
website: | ||
container_name: storagebox-website | ||
build: | ||
context: ./website | ||
dockerfile: Dockerfile | ||
ports: | ||
- "4001:4001" | ||
depends_on: | ||
- server |
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 +1,16 @@ | ||
DATABASE_URL="postgresql://postgres:123@localhost:5432/postgres" | ||
JWT_SECRET=your-secret-key | ||
|
||
DATABASE_URL=postgresql://postgres:123@localhost:5432/postgres | ||
REDIS_URL=redis://localhost:6379/0 | ||
|
||
GITHUB_CLIENT_SECRET= | ||
GITHUB_CLIENT_ID= | ||
GITHUB_REDIRECT_URI=http://localhost:4001/auth/github | ||
|
||
DISCORD_CLIENT_SECRET= | ||
DISCORD_CLIENT_ID= | ||
DISCORD_REDIRECT_URI=http://localhost:4001/auth/discord | ||
|
||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
GOOGLE_REDIRECT_URI=http://localhost:4001/auth/google |
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,3 +1,2 @@ | ||
.env | ||
.envv | ||
uploads/* |
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,20 +1,14 @@ | ||
FROM golang:1.21.1 | ||
|
||
# Set destination for COPY | ||
WORKDIR /app | ||
|
||
# Download Go modules | ||
COPY . . | ||
|
||
# Build | ||
# RUN go run github.com/steebchen/prisma-client-go db push | ||
# RUN CGO_ENABLED=0 GOOS=linux go build -o /main | ||
|
||
# ENV JWT_SECRET=your-secret-key | ||
# ENV DATABASE_URL=postgresql://postgres:123@sbp:5432/tus | ||
# ENV REDIS_URL=redis://sbr:6379/0 | ||
RUN go mod download | ||
|
||
EXPOSE 4000 | ||
|
||
COPY build-and-run.sh /app/build-and-run.sh | ||
RUN chmod +x /app/build-and-run.sh | ||
|
||
ENTRYPOINT ["/app/build-and-run.sh"] |
This file was deleted.
Oops, something went wrong.
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
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,42 @@ | ||
package middleware | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/AlandSleman/StorageBox/config" | ||
"github.com/gin-gonic/gin" | ||
"github.com/redis/go-redis/v9" | ||
limiter "github.com/ulule/limiter/v3" | ||
mgin "github.com/ulule/limiter/v3/drivers/middleware/gin" | ||
sredis "github.com/ulule/limiter/v3/drivers/store/redis" | ||
) | ||
|
||
func RateLimit() gin.HandlerFunc { | ||
rate, err := limiter.NewRateFromFormatted("70-M") | ||
if err != nil { | ||
log.Fatal(err) | ||
os.Exit(1) | ||
} | ||
|
||
// Create a redis client. | ||
option, err := redis.ParseURL(config.GetConfig().REDIS_URL) | ||
if err != nil { | ||
log.Fatal("errris:", err) | ||
os.Exit(1) | ||
} | ||
client := redis.NewClient(option) | ||
|
||
// Create a store with the redis client. | ||
store, err := sredis.NewStoreWithOptions(client, limiter.StoreOptions{ | ||
Prefix: "limiter", | ||
MaxRetry: 3, | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
os.Exit(1) | ||
} | ||
|
||
// Create a new middleware with the limiter instance. | ||
return mgin.NewMiddleware(limiter.New(store, rate)) | ||
} |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
node_modules/ | ||
.next/ |
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
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,22 @@ | ||
# Use an official Node.js runtime as a parent image | ||
FROM node:20 | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY . . | ||
|
||
# Install project dependencies | ||
RUN npm i -g pnpm | ||
RUN pnpm install | ||
|
||
|
||
# Build your Next.js app | ||
RUN pnpm build | ||
|
||
# Expose the port that your Next.js app will run on | ||
EXPOSE 4001 | ||
|
||
# Define the command to run your Next.js app | ||
CMD ["pnpm", "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
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,14 +1,8 @@ | ||
// export let apiUrl = process.env.PRODUCTION | ||
// ? "https://apii.kurdmake.com" | ||
// : "http://localhost:4000" | ||
export let serverUrl = "http://localhost:4000" | ||
export let localServerUrl = "http://localhost:4000" | ||
export let GITHUB_CLIENT_ID = "c98212440d44388b3ac6" | ||
export let GITHUB_REDIRECT_URI = "http://localhost:4001/auth/github" | ||
|
||
export let DISCORD_CLIENT_ID = "1154194839299170344" | ||
export let DISCORD_REDIRECT_URI = "http://localhost:4001/auth/discord" | ||
|
||
export let GOOGLE_CLIENT_ID = | ||
"198565811833-bcdtkf2qro3fpeo204pnfkt5dial4tbd.apps.googleusercontent.com" | ||
export let GOOGLE_REDIRECT_URI = "http://localhost:4001/auth/google" | ||
export const serverUrl = process.env.SERVER_URL; | ||
export const localServerUrl = process.env.LOCAL_SERVER_URL; | ||
export const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID; | ||
export const GITHUB_REDIRECT_URI = process.env.GITHUB_REDIRECT_URI; | ||
export const DISCORD_CLIENT_ID = process.env.DISCORD_CLIENT_ID; | ||
export const DISCORD_REDIRECT_URI = process.env.DISCORD_REDIRECT_URI; | ||
export const GOOGLE_CLIENT_ID = process.env.GOOGLE_CLIENT_ID; | ||
export const GOOGLE_REDIRECT_URI = process.env.GOOGLE_REDIRECT_URI; |