Prepare build and deployment
This commit is contained in:
parent
c810c34b97
commit
e40ffc00c3
7 changed files with 114 additions and 18 deletions
32
.drone.yml
Normal file
32
.drone.yml
Normal file
|
@ -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
|
13
api/Dockerfile
Normal file
13
api/Dockerfile
Normal file
|
@ -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"]
|
|
@ -5,7 +5,6 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from evaluators import dialog_gpt
|
from evaluators import dialog_gpt
|
||||||
from evaluators import roberta
|
from evaluators import roberta
|
||||||
from evaluators.dalle import dalle
|
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
@ -84,23 +83,23 @@ def get_continuation(text: str) -> str:
|
||||||
return dialog_gpt.dialogGPT.eval(text)
|
return dialog_gpt.dialogGPT.eval(text)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/dalle/generate")
|
# @app.get("/dalle/generate")
|
||||||
def get_image(text: str):
|
# def get_image(text: str):
|
||||||
text_prompt = text
|
# text_prompt = text
|
||||||
generated_imgs = dalle.dallE.eval(text_prompt, 2)
|
# generated_imgs = dalle.dallE.eval(text_prompt, 2)
|
||||||
|
|
||||||
returned_generated_images = []
|
# returned_generated_images = []
|
||||||
dir_name = os.path.join("/home/armin/Desktop/dalle", f"{time.strftime('%Y-%m-%d_%H:%M:%S')}_{text_prompt}")
|
# 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)
|
# Path(dir_name).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
for idx, img in enumerate(generated_imgs):
|
# for idx, img in enumerate(generated_imgs):
|
||||||
img.save(os.path.join(dir_name, f'{idx}.png'), format="png")
|
# 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,
|
# response = {'generatedImgs': returned_generated_images,
|
||||||
'generatedImgsFormat': "img"}
|
# 'generatedImgsFormat': "img"}
|
||||||
return response
|
# return response
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
48
web/Dockerfile
Normal file
48
web/Dockerfile
Normal file
|
@ -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"]
|
|
@ -8,7 +8,7 @@ export default function Continuation(props) {
|
||||||
|
|
||||||
|
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
basePath: 'http://localhost:8000'
|
basePath: 'https://api.alas.friedl.net'
|
||||||
});
|
});
|
||||||
|
|
||||||
const api = new DefaultApi(configuration);
|
const api = new DefaultApi(configuration);
|
||||||
|
@ -50,4 +50,4 @@ export default function Continuation(props) {
|
||||||
</Row>
|
</Row>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default function TextInput(props) {
|
||||||
}) }, [text])
|
}) }, [text])
|
||||||
|
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
basePath: 'http://localhost:8000'
|
basePath: 'https://api.alas.friedl.net'
|
||||||
});
|
});
|
||||||
|
|
||||||
const api = new DefaultApi(configuration);
|
const api = new DefaultApi(configuration);
|
||||||
|
@ -165,4 +165,4 @@ export default function TextInput(props) {
|
||||||
</Container>
|
</Container>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
output: 'standalone',
|
||||||
|
experimental: {
|
||||||
|
outputStandalone: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = nextConfig
|
module.exports = nextConfig
|
||||||
|
|
Loading…
Reference in a new issue