-
Notifications
You must be signed in to change notification settings - Fork 4
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
0 parents
commit 076c8a5
Showing
58 changed files
with
9,460 additions
and
0 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,7 @@ | ||
Dockerfile | ||
.dockerignore | ||
node_modules | ||
npm-debug.log | ||
README.md | ||
.next | ||
.git |
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,8 @@ | ||
# Please set the API KEY and your app name bellow | ||
NEXT_PUBLIC_SITE_NAME=My Midjourney App | ||
MIDJOURNEY_API_KEY= | ||
|
||
# Please leave the following variables as is | ||
NEXT_PUBLIC_MIDJOURNEY_API_URL=https://api.mymidjourney.ai/api/v1 | ||
NEXT_PUBLIC_ENABLE_TOKEN_PAYMENT=false # Set to true if you want to enable token payment in UI, user management is required before enable this | ||
NEXT_PUBLIC_ENABLE_IMAGE_TO_IMAGE=false # Set to true if you want to enable image to image, file upload is required before enable this |
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,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
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,38 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-project: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install dependencies and build | ||
run: npm install && npm run build | ||
docker-build-push: | ||
needs: build-project | ||
name: Build and Push Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Login to docker hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/midjourney-ai-app:${{ github.sha }} |
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,35 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
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,9 @@ | ||
{ | ||
"arrowParens": "always", | ||
"semi": false, | ||
"endOfLine": "auto", | ||
"singleQuote": false, | ||
"tabWidth": 2, | ||
"trailingComma": "es5", | ||
"plugins": ["prettier-plugin-organize-imports"] | ||
} |
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,65 @@ | ||
FROM node:18-alpine AS base | ||
|
||
# Install dependencies only when needed | ||
FROM base AS deps | ||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN yarn build | ||
|
||
# If using npm comment out above and use below instead | ||
# RUN npm run build | ||
|
||
# Production image, copy all the files and run next | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
# Uncomment the following line in case you want to disable telemetry during runtime. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
# Set the correct permission for prerender cache | ||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
# set hostname to localhost | ||
ENV HOSTNAME "0.0.0.0" | ||
|
||
CMD ["node", "server.js"] |
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,66 @@ | ||
# Midjourney AI APP | ||
|
||
A open source web app for midjourney AI art generation. | ||
|
||
# Deploy to Vercel | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fiamzifei%2Fmidjourney-ai-app&env=NEXT_PUBLIC_SITE_NAME,MIDJOURNEY_API_KEY,NEXT_PUBLIC_MIDJOURNEY_API_URL&envDescription=Environment%20variables%20needed%20for%20the%20free%20version%20deployment&envLink=https%3A%2F%2Fgithub.com%2Fiamzifei%2Fmidjourney-ai-app%2Fblob%2Fmain%2F.env.template) | ||
|
||
## Keywords | ||
|
||
- Midjourney | ||
- Midjourney AI | ||
- Midjourney API | ||
- Midjourney art | ||
- Midjourney UI | ||
- Midjourney App | ||
- Midjourney App Demo | ||
- Free Midjourney App | ||
- Open source Midjourney app | ||
- Open source Midjourney web app | ||
|
||
## Demo | ||
|
||
![](/doc/demo.gif) | ||
|
||
## Todo | ||
|
||
### Community Version | ||
|
||
- [x] midjourney web UI for the most general image actions, such as Imagine, Vary, Reroll | ||
- [ ] midjourney web UI for the advanced actions, such as Zoom, Pan, In-Painting, Blend, etc | ||
- [ ] midjourney web UI for the advanced actions, such as Partial Redraw, Settings, Describe, Seed, etc | ||
- [ ] better UI/UX for non-tech background users | ||
- [ ] multi-language support | ||
|
||
### Need more features? Please check out [the Pro version](https://github.com/iamzifei/midjourney-ai-app/tree/Pro), including features such as payment, user management, complete Midjourney features support and more! | ||
|
||
## How to use | ||
|
||
- copy the `.env.template` to `.env`, and fill up the values | ||
- put your [Mymidjourney API Key](https://www.mymidjourney.ai/blog/midjourney-api-request) for the env variable `MIDJOURNEY_API_KEY` in the `.env` file | ||
- start the app locally or deploy it to online services like [Vercel](https://vercel.com) | ||
|
||
## Tech stack | ||
|
||
- [NextJS](https://nextjs.org/) | ||
- [Midjourney API](https://www.mymidjourney.ai/) | ||
|
||
## Local start | ||
|
||
```bash | ||
npm i && npm run dev | ||
# or | ||
yarn && yarn dev | ||
# or | ||
pnpm i && pnpm dev | ||
``` | ||
|
||
## Support | ||
|
||
[My Telegram Channel](https://t.me/+PYmwNF-6_9s4OTI1) | ||
|
||
## References | ||
|
||
- [MyMidjourney API](https://www.mymidjourney.ai/) | ||
- [MyMidjourney API Docs](https://www.mymidjourney.ai/docs) |
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,16 @@ | ||
"use client" | ||
|
||
import { Toaster } from "react-hot-toast" | ||
|
||
const CommonClient = () => { | ||
return ( | ||
<Toaster | ||
toastOptions={{ | ||
className: | ||
"flex w-full max-w-xs text-sm sm:text-base items-center rounded-lg bg-white p-4 text-neutral-900 shadow dark:bg-gray-800 dark:text-neutral-200", | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
export default CommonClient |
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,96 @@ | ||
"use client" | ||
|
||
import { QuestionMarkCircleIcon } from "@heroicons/react/24/outline" | ||
import PlaceholderImage from "@images/painting-placeholder.png" | ||
import { useImagineContext } from "@lib/context/imagine-context" | ||
|
||
import Banner from "@shared/Banner" | ||
import Button from "@shared/Button/Button" | ||
import Tooltip from "@shared/Tooltip" | ||
import { useRouter } from "next/navigation" | ||
import StepPrompt from "./StepPrompt" | ||
|
||
type ImagineProps = { | ||
session: any | ||
} | ||
|
||
const ENABLE_TOKEN_PAYMENT = | ||
process.env.NEXT_PUBLIC_ENABLE_TOKEN_PAYMENT === "true" | ||
|
||
export default function Imagine({ session }: ImagineProps) { | ||
const { aiImage } = useImagineContext() | ||
const { push } = useRouter() | ||
|
||
const handleBuyCredit = () => { | ||
push("/credits") | ||
} | ||
|
||
return ( | ||
<div className="pt-4"> | ||
{session ? ( | ||
<div className="container"> | ||
<h2 className="my-4 mt-6 text-xl font-semibold !leading-[1.2] tracking-tight sm:my-6 sm:mt-10 sm:text-2xl xl:text-3xl 2xl:text-4xl"> | ||
Create your own masterpiece... | ||
</h2> | ||
<div> | ||
<StepPrompt session={session} /> | ||
|
||
{ENABLE_TOKEN_PAYMENT && ( | ||
<div className="mb-8 flex flex-col items-center justify-between gap-x-4 px-4 sm:flex-row"> | ||
<div className="text-sm text-gray-500 dark:text-gray-400"> | ||
<div> | ||
<span className="font-semibold">Note:</span> | ||
{` Please note that | ||
each A.I. painting generation, upscaling, or variation requires `} | ||
<span className="font-semibold">1</span> | ||
{` credit, which will be | ||
deducted from your account upon completion. `} | ||
<Tooltip | ||
label="why this" | ||
icon={<QuestionMarkCircleIcon className="h-4 w-4" />} | ||
tip={ | ||
<> | ||
<p> | ||
{`We're committed to providing you with top-notch | ||
AI-generated artwork and image enhancements. To | ||
maintain the highest quality and seamless experience, | ||
we invest in cutting-edge AI resources and | ||
infrastructure, including powerful GPU servers.`} | ||
</p> | ||
<p className="mt-4"> | ||
{`Each credit you use helps cover the cost of these | ||
resources, ensuring that you receive the best possible | ||
results. Your support enables us to continue offering | ||
innovative, high-quality AI services that bring your | ||
creative visions to life. Thank you for being a part | ||
of our creative community!`} | ||
</p> | ||
</> | ||
} | ||
/> | ||
</div> | ||
</div> | ||
<Button | ||
onClick={handleBuyCredit} | ||
className="mt-3 flex !h-9 w-48 min-w-[128px] items-center justify-center rounded-2xl border border-neutral-200 bg-neutral-200/70 px-4 !text-sm !font-medium text-neutral-700 transition-colors hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-800 sm:ml-3 sm:mt-0" | ||
> | ||
Buy Credits | ||
</Button> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="container py-8 sm:py-16"> | ||
<Banner | ||
headline="Artistry Unleashed" | ||
description="Experience the magic of AI as it transforms your vision into stunning artwork. Customize, visualize, and bring your creativity to life with our AI painting generation feature." | ||
buttonLabel="Login" | ||
buttonLink="/account/login" | ||
image={PlaceholderImage} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} |
Oops, something went wrong.