diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..4d9392f --- /dev/null +++ b/.drone.yml @@ -0,0 +1,32 @@ +kind: pipeline +type: docker +name: default + +steps: +- name: publish-web + image: plugins/docker + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + dockerfile: web/Dockerfile + context: web + purge: true + pull_image: true + repo: arminfriedl/alas-web + tags: latest + +- name: publish-api + image: plugins/docker + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + dockerfile: api/Dockerfile + context: api + purge: true + pull_image: true + repo: arminfriedl/alas-api + tags: latest diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..ff9f279 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.10 + +WORKDIR /app +COPY . . +RUN pip install poetry +RUN poetry install +RUN pip install uvicorn + +EXPOSE 8000 +ENV PORT 8000 + +WORKDIR alas +CMD ["poetry","run","uvicorn", "--host", "0.0.0.0", "main:app"] diff --git a/api/alas/main.py b/api/alas/main.py index 6ee9cc0..2848063 100644 --- a/api/alas/main.py +++ b/api/alas/main.py @@ -5,7 +5,6 @@ from fastapi.middleware.cors import CORSMiddleware from evaluators import dialog_gpt from evaluators import roberta -from evaluators.dalle import dalle from pydantic import BaseModel @@ -84,23 +83,23 @@ def get_continuation(text: str) -> str: return dialog_gpt.dialogGPT.eval(text) -@app.get("/dalle/generate") -def get_image(text: str): - text_prompt = text - generated_imgs = dalle.dallE.eval(text_prompt, 2) +# @app.get("/dalle/generate") +# def get_image(text: str): +# text_prompt = text +# generated_imgs = dalle.dallE.eval(text_prompt, 2) - returned_generated_images = [] - dir_name = os.path.join("/home/armin/Desktop/dalle", f"{time.strftime('%Y-%m-%d_%H:%M:%S')}_{text_prompt}") - Path(dir_name).mkdir(parents=True, exist_ok=True) +# returned_generated_images = [] +# dir_name = os.path.join("/home/armin/Desktop/dalle", f"{time.strftime('%Y-%m-%d_%H:%M:%S')}_{text_prompt}") +# Path(dir_name).mkdir(parents=True, exist_ok=True) - for idx, img in enumerate(generated_imgs): - img.save(os.path.join(dir_name, f'{idx}.png'), format="png") +# for idx, img in enumerate(generated_imgs): +# img.save(os.path.join(dir_name, f'{idx}.png'), format="png") - print(f"Created {2} images from text prompt [{text_prompt}]") +# print(f"Created {2} images from text prompt [{text_prompt}]") - response = {'generatedImgs': returned_generated_images, - 'generatedImgsFormat': "img"} - return response +# response = {'generatedImgs': returned_generated_images, +# 'generatedImgsFormat': "img"} +# return response if __name__ == "__main__": diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..b2270bd --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,48 @@ +# Install dependencies only when needed +FROM node:16-alpine 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 +COPY package.json package-lock.json ./ +RUN npm ci + +# Rebuild the source code only when needed +FROM node:16-alpine 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 npm run build --production + +# Production image, copy all the files and run next +FROM node:16-alpine 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 + +# You only need to copy next.config.js if you are NOT using the default configuration +COPY --from=builder /app/next.config.js ./ +COPY --from=builder /app/public ./public +COPY --from=builder /app/package.json ./package.json + +# 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 + +CMD ["node", "server.js"] diff --git a/web/components/Continuation.tsx b/web/components/Continuation.tsx index d5b8bd6..d8616b3 100644 --- a/web/components/Continuation.tsx +++ b/web/components/Continuation.tsx @@ -8,7 +8,7 @@ export default function Continuation(props) { const configuration = new Configuration({ - basePath: 'http://localhost:8000' + basePath: 'https://api.alas.friedl.net' }); const api = new DefaultApi(configuration); @@ -50,4 +50,4 @@ export default function Continuation(props) { ); -} \ No newline at end of file +} diff --git a/web/components/TextInput.tsx b/web/components/TextInput.tsx index 855d32f..5a91c0f 100644 --- a/web/components/TextInput.tsx +++ b/web/components/TextInput.tsx @@ -21,7 +21,7 @@ export default function TextInput(props) { }) }, [text]) const configuration = new Configuration({ - basePath: 'http://localhost:8000' + basePath: 'https://api.alas.friedl.net' }); const api = new DefaultApi(configuration); @@ -165,4 +165,4 @@ export default function TextInput(props) { ) -} \ No newline at end of file +} diff --git a/web/next.config.js b/web/next.config.js index a843cbe..54765b6 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -1,6 +1,10 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + output: 'standalone', + experimental: { + outputStandalone: true, + } } module.exports = nextConfig