Deployment WIP

This commit is contained in:
2025-02-22 23:35:46 +01:00
parent 574a738868
commit 78277906fe
9 changed files with 83 additions and 17 deletions
+6
View File
@@ -3,3 +3,9 @@ charset = utf-8
indent_style = tab
indent_size = 2
quote_type= single
[*.{go}]
charset = utf-8
indent_style = tab
indent_size = 2
quote_type= double
+2 -2
View File
@@ -8,9 +8,9 @@ lerna-debug.log*
node_modules
dist
dist-ssr
build
*.local
.env
.env*
# Editor directories and files
.vscode/*
+36
View File
@@ -0,0 +1,36 @@
FROM node:20-alpine AS frontend
WORKDIR /frontend
COPY ./client .
RUN npm install
RUN npm run build
FROM golang:1.23-alpine AS backend
WORKDIR /backend
COPY ./server .
RUN go mod tidy
RUN go build -o server
# FROM ollama/ollama:latest AS ai
# Install the llama3.2:1b model
# RUN ollama pull llama3.2:1b
# Stage 4: Setup NGINX to serve the React app and reverse proxy the Go and Ollama servers
FROM nginx:alpine AS reverse_proxy
# Copy the React build from the previous stage to NGINX's HTML folder
COPY --from=frontend /frontend/build /usr/share/nginx/html
# Copy the Go server binary into the container
COPY --from=backend /backend/.env.production .env
COPY --from=backend /backend/server /usr/local/bin/server
# Copy NGINX configuration to configure reverse proxy
COPY ./nginx.conf /etc/nginx/nginx.conf
# Expose necessary ports
EXPOSE 80
EXPOSE 8080
# Start NGINX and Go server in parallel (using a simple entrypoint script)
CMD ["sh", "-c", "nginx -g 'daemon off;' & /usr/local/bin/server"]
-2
View File
@@ -16,8 +16,6 @@
property="og:description"
content="Master touch typing with real code snippets from your favorite programming languages, powered by AI."
>
<meta property="og:url" content=".">
<link rel="canonical" href=".">
<link rel="icon" sizes="192x192" href="android-chrome-192x192.png">
<link rel="icon" sizes="512x512" href="android-chrome-512x512.png">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
+1 -1
View File
@@ -6,7 +6,7 @@ import App from './App.tsx';
import './index.css';
// TODO: Bring back strict mode when building and deploying
createRoot(document.getElementById('root')).render(
createRoot(document.querySelector('#root') as HTMLElement).render(
<BrowserRouter>
<App />
</BrowserRouter>
+31
View File
@@ -0,0 +1,31 @@
events {}
http {
upstream backend {
server 127.0.0.1:8080;
}
upstream ai {
server 127.0.0.1:11434;
}
server {
listen 80;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
location ~* \.(?:css|js)$ {
try_files $uri/ =404;
}
location /api/ {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
-5
View File
@@ -1,5 +0,0 @@
[*.{go}]
charset = utf-8
indent_style = tab
indent_size = 2
quote_type= double
+1 -1
View File
@@ -135,7 +135,7 @@ func Generate(ctx echo.Context) error {
return nil
}
return ctx.String(http.StatusInternalServerError, "Error generating code!")
return ctx.String(http.StatusInternalServerError, "Error generating code: " + err.Error())
}
return nil
+6 -6
View File
@@ -15,7 +15,7 @@ func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading environment!")
log.Fatal("Error loading environment: ", err.Error())
}
PORT := os.Getenv("PORT")
@@ -34,11 +34,11 @@ func main() {
}
ech.Logger.Fatal(ech.Start(fmt.Sprintf(":%s", PORT)))
}
} else {
if len(PORT) == 0 {
PORT = "4443"
}
if len(PORT) == 0 {
PORT = "4443"
ech.Logger.Fatal(ech.StartTLS(fmt.Sprintf(":%s", PORT), SSL_CERT_PATH, SSL_KEY_PATH))
}
ech.Logger.Fatal(ech.StartTLS(fmt.Sprintf(":%s", PORT), SSL_CERT_PATH, SSL_KEY_PATH))
}