Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize #1

Open
thegreathir opened this issue Dec 11, 2023 · 7 comments
Open

Dockerize #1

thegreathir opened this issue Dec 11, 2023 · 7 comments

Comments

@thegreathir
Copy link

Hi,
I don't know JS :)) (I should read the book)
Could you please dockerize this so I can test it?
It would be nice to input the OpenAI token from the env vars.

@gregsadetsky
Copy link
Owner

hey,

adding instructions on how to run it would be a great idea! for now, you should be able to:

  • git clone the repo
  • create a .env file, and have a single VITE_OPENAI_KEY="sk-..." value in there with a proper openai key
  • run npm install and then npm run dev
  • at that point you should have a local web server running at http://localhost:5173

let me know if this works!

@thegreathir
Copy link
Author

I've asked ChatGPT for a Dockerfile related to a JS Vite (I've found it from your package.json ) project:

# Use an official Node.js runtime as a base image
FROM node:14

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install project dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Build the Vite project
RUN npm run build

# Expose the port your app runs on (adjust this based on your Vite configuration)
EXPOSE 5000

# Command to run your application
CMD ["npm", "run", "start"]

I think I can update the Dockerfile from the information you've provided (I can't use it directly since I haven't installed npm, and I won't actually :))) ).

@gregsadetsky
Copy link
Owner

this looks roughly correct, although I'd suggest a more up to date version of Node. the other thing is that npm run start will probably not be recognized as a command (unless you add it to the package.json). you might want to add a serve to package.json and then add/run https://www.npmjs.com/package/serve

just brainstorming -- didn't try it out

@thegreathir
Copy link
Author

# Use an official Node.js runtime as a base image
FROM node:18

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install project dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

RUN mv demo.html index.html

ARG OPENAI_KEY
ENV VITE_OPENAI_KEY=$OPENAI_KEY

# Build the Vite project
RUN npm run build

# Expose the port your app runs on (adjust this based on your Vite configuration)
EXPOSE 5173

# Command to run your application
CMD ["npm", "run", "dev"]

This is working now :)))

@thegreathir
Copy link
Author

docker build -t sagittarius --build-arg OPENAI_KEY="sk-..." .
docker run --net=host sagittarius

@thegreathir
Copy link
Author

thegreathir commented Dec 11, 2023

I can submit a PR for that if you find it useful :))

@gregsadetsky
Copy link
Owner

congrats on making it work! let me take a look & potentially clean up the repo a bit (moving the public page to docs/, having a proper readme, etc.) and I'll look into it. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants