Compare commits
3 Commits
691a340ad4
...
PIE-9
| Author | SHA1 | Date | |
|---|---|---|---|
|
e6c86d8391
|
|||
|
ee9cb8972a
|
|||
|
82c9c5b826
|
50
Dockerfile.combined
Normal file
50
Dockerfile.combined
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Multi-stage build combining both services
|
||||||
|
|
||||||
|
# Stage 1: Build the Node.js/Astro application
|
||||||
|
FROM node:24-alpine AS app-builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm i
|
||||||
|
COPY . .
|
||||||
|
ENV PUBLIC_PB_URL=http://localhost:8080
|
||||||
|
ENV PUBLIC_URL=http://localhost:4321
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
ARG PB_VERSION=0.29.2
|
||||||
|
|
||||||
|
WORKDIR /pb
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
unzip \
|
||||||
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
bash \
|
||||||
|
nodejs \
|
||||||
|
npm
|
||||||
|
|
||||||
|
# Download and unzip PocketBase
|
||||||
|
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
|
||||||
|
RUN unzip /tmp/pb.zip -d /pb/
|
||||||
|
|
||||||
|
# Copy PocketBase entrypoint
|
||||||
|
COPY api/docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
|
# # Set environment variables (keeping them as they are)
|
||||||
|
# ENV PUBLIC_PB_URL=http://pb:8080
|
||||||
|
# ENV PUBLIC_URL=http://localhost:4321
|
||||||
|
|
||||||
|
VOLUME [ "/pb/pb_data", "/pb/pb_migrations", "/pb/pb_hooks" ]
|
||||||
|
# VOLUME [ "/pb/pb_data" ]
|
||||||
|
|
||||||
|
EXPOSE 8080 4321
|
||||||
|
|
||||||
|
# Create a startup script that runs both services
|
||||||
|
RUN echo '#!/bin/bash' > /usr/local/bin/start-services.sh && \
|
||||||
|
echo 'cd /pb && docker-entrypoint.sh serve --http=0.0.0.0:8080 &' >> /usr/local/bin/start-services.sh && \
|
||||||
|
echo 'cd /app && npm run preview -- --host &' >> /usr/local/bin/start-services.sh && \
|
||||||
|
echo 'wait' >> /usr/local/bin/start-services.sh && \
|
||||||
|
chmod +x /usr/local/bin/start-services.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["start-services.sh"]
|
||||||
|
|
||||||
@@ -1,16 +1,30 @@
|
|||||||
|
# services:
|
||||||
|
# web:
|
||||||
|
# build: .
|
||||||
|
# env_file: .env
|
||||||
|
# ports:
|
||||||
|
# - "4321:4321"
|
||||||
|
|
||||||
|
# pb:
|
||||||
|
# build: api
|
||||||
|
# env_file: .env
|
||||||
|
# volumes:
|
||||||
|
# - ./api/pb_data:/pb/pb_data
|
||||||
|
# - ./api/pb_migrations:/pb/pb_migrations
|
||||||
|
# - ./api/pb_hooks:/pb/pb_hooks
|
||||||
|
# ports:
|
||||||
|
# - "8080:8080"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
recipie:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.combined
|
||||||
env_file: .env
|
env_file: .env
|
||||||
ports:
|
ports:
|
||||||
- "4321:4321"
|
- "4321:4321"
|
||||||
|
- "8080:8080" # optional, for manual pocketbase access
|
||||||
pb:
|
|
||||||
build: api
|
|
||||||
env_file: .env
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./api/pb_data:/pb/pb_data
|
- ./api/pb_data:/pb/pb_data
|
||||||
- ./api/pb_migrations:/pb/pb_migrations
|
- ./api/pb_migrations:/pb/pb_migrations
|
||||||
- ./api/pb_hooks:/pb/pb_hooks
|
- ./api/pb_hooks:/pb/pb_hooks
|
||||||
ports:
|
|
||||||
- "8080:8080"
|
|
||||||
@@ -19,7 +19,7 @@ const tableView = true
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{tableView && (
|
{tableView && (
|
||||||
<table class={`table-auto text-left bg-[#2a2b2c] rounded-lg ${className}`}>
|
<table class={`table-auto text-left bg-[#2a2b2c] rounded-lg ${className} w-full`}>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="px-4 py-2">Quantity</th>
|
<th class="px-4 py-2">Quantity</th>
|
||||||
@@ -29,9 +29,9 @@ const tableView = true
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{
|
{
|
||||||
ingredients.map((ing, index) => (
|
ingredients.map(ing => (
|
||||||
<>
|
<>
|
||||||
<tr class="border-t border-white/10 cursor-pointer hover:bg-white/10 transition-opacity ingredient-row" data-index={index}>
|
<tr class="border-t border-gray-600">
|
||||||
<td class="px-4 py-2">{ing.quantity}</td>
|
<td class="px-4 py-2">{ing.quantity}</td>
|
||||||
<td class="px-4 py-2">{ing.unit}</td>
|
<td class="px-4 py-2">{ing.unit}</td>
|
||||||
<td class="px-4 py-2">{ing.name}</td>
|
<td class="px-4 py-2">{ing.name}</td>
|
||||||
@@ -42,27 +42,3 @@ const tableView = true
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<style>
|
|
||||||
.ingredient-row.completed {
|
|
||||||
/* background-color: rgba(0, 0, 0, 0.4) !important; */
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ingredient-row.completed td {
|
|
||||||
text-decoration: line-through;
|
|
||||||
color: rgba(255, 255, 255, 0.5);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const rows = document.querySelectorAll('.ingredient-row');
|
|
||||||
|
|
||||||
rows.forEach(row => {
|
|
||||||
row.addEventListener('click', function() {
|
|
||||||
this.classList.toggle('completed');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -10,7 +10,7 @@ const ings = await Promise.all(
|
|||||||
|
|
||||||
<div class={className}>
|
<div class={className}>
|
||||||
{ings.map(i => (
|
{ings.map(i => (
|
||||||
<div class="text-sm">
|
<div>
|
||||||
<p>• {i.quantity} {i.unit || " "} {i.name}</p>
|
<p>• {i.quantity} {i.unit || " "} {i.name}</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import { record } from "astro:schema"
|
|||||||
import client from "@/data/pocketbase"
|
import client from "@/data/pocketbase"
|
||||||
import StepIngredientSideView from "./StepIngredientSideView.astro"
|
import StepIngredientSideView from "./StepIngredientSideView.astro"
|
||||||
|
|
||||||
const { steps, class: className } = Astro.props
|
const { steps } = Astro.props
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class={className}>
|
<div class="md:ml-5 mt-2 md:mt-0">
|
||||||
<p class="text-[22pt] font-bold md:hidden">Steps</p>
|
<p class="text-[22pt] font-bold md:hidden">Steps</p>
|
||||||
{ steps.map(s => (
|
{ steps.map(s => (
|
||||||
<div class="bg-[#2a2b2c] rounded-lg mb-2 p-3">
|
<div class="bg-[#2a2b2c] rounded-lg mb-2 p-3">
|
||||||
@@ -15,7 +15,7 @@ const { steps, class: className } = Astro.props
|
|||||||
<div class="flex flex-col md:flex-row md:items-stretch">
|
<div class="flex flex-col md:flex-row md:items-stretch">
|
||||||
<p class="w-full md:flex-2/3 pr-1 text-left">{s.instruction}</p>
|
<p class="w-full md:flex-2/3 pr-1 text-left">{s.instruction}</p>
|
||||||
{s.ingredients && s.ingredients.length > 0 && (
|
{s.ingredients && s.ingredients.length > 0 && (
|
||||||
<div class="w-full md:w-auto md:flex-2/5 mt-2 md:mt-0 md:ml-2 md:pl-3 md:border-l text-white/70 border-white/70">
|
<div class="w-full md:w-auto md:flex-1/3 mt-2 md:mt-0 md:ml-2 md:pl-3 md:border-l text-white/70 border-white/70">
|
||||||
<StepIngredientSideView class="text-left" ingredients={s.ingredients} />
|
<StepIngredientSideView class="text-left" ingredients={s.ingredients} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="ml-auto space-x-5">
|
<div class="ml-auto space-x-5">
|
||||||
<a class="hover:underline underline-offset-4 " href="/recipe/new">new</a>
|
<a>new</a>
|
||||||
<a class="hover:underline underline-offset-4 " >tags</a>
|
<a>tags</a>
|
||||||
<a class="hover:underline underline-offset-4 " >search</a>
|
<a>search</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,10 +28,10 @@ const ingredients = await Promise.all(
|
|||||||
---
|
---
|
||||||
|
|
||||||
<SiteLayout>
|
<SiteLayout>
|
||||||
<div class="flex flex-col md:flex-row mx-auto justify-center w-full lg:max-w-3/4 xl:max-w-2/3 2xl:max-w-1/2">
|
<div class="flex flex-col md:flex-row">
|
||||||
<div class="flex md:flex-1/3 flex-col mt-2 md:mt-4 sticky">
|
<div class="flex flex-col mt-2 md:mt-4 sticky">
|
||||||
<ImageCarousel class="w-full" recipe={re} />
|
<ImageCarousel class="w-full" recipe={re} />
|
||||||
<p class="text-[28pt] font-bold leading-11 mt-2">{re.name}</p>
|
<p class=" md:hidden text-[28pt] font-bold leading-none mt-2">{re.name}</p>
|
||||||
|
|
||||||
<!-- Details -->
|
<!-- Details -->
|
||||||
<InfoView re={re} />
|
<InfoView re={re} />
|
||||||
@@ -40,9 +40,11 @@ const ingredients = await Promise.all(
|
|||||||
<IngredientTableView class:list={['md:w-80', 'px-4']} ingredients={ingredients} />
|
<IngredientTableView class:list={['md:w-80', 'px-4']} ingredients={ingredients} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex mt-4 md:flex-2/3 w-full flex-col">
|
<div class="flex w-full flex-col">
|
||||||
|
<p class="hidden md:block text-[28pt] font-bold pl-5">{re.name}</p>
|
||||||
|
|
||||||
<!-- Steps -->
|
<!-- Steps -->
|
||||||
<StepView class="md:ml-3" steps={steps} />
|
<StepView steps={steps} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
---
|
|
||||||
import SiteLayout from "@/layouts/base";
|
|
||||||
|
|
||||||
const { recipeid } = Astro.params;
|
|
||||||
|
|
||||||
// Actually post the recipe with the stored variables
|
|
||||||
async function submitRecipe() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
---
|
|
||||||
<script src="@/script/newRecipe.ts"/>
|
|
||||||
|
|
||||||
<SiteLayout>
|
|
||||||
<div class="flex flex-col md:flex-row mx-auto justify-center w-full lg:max-w-3/4 xl:max-w-2/3 2xl:max-w-1/2">
|
|
||||||
<div class="flex md:flex-1/3 flex-col mt-2 md:mt-4 sticky">
|
|
||||||
<div class="relative">
|
|
||||||
<input
|
|
||||||
id="photo"
|
|
||||||
type="file"
|
|
||||||
accept="image/png,image/jpeg"
|
|
||||||
class="w-full bg-white/10 rounded-lg h-50
|
|
||||||
file:mr-4 file:py-2 file:px-4
|
|
||||||
file:rounded-lg file:border-0 file:hidden
|
|
||||||
before:content-['camera'] before:w-full before:h-full before:flex
|
|
||||||
before:items-center before:justify-center before:absolute
|
|
||||||
relative cursor-pointer
|
|
||||||
[&::-webkit-file-upload-button]:hidden"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<textarea
|
|
||||||
id="rec-name"
|
|
||||||
rows="1"
|
|
||||||
placeholder="Name"
|
|
||||||
class="text-[28pt] font-bold p-1 leading-none mt-2 bg-white/10 rounded-lg resize-none overflow-hidden"
|
|
||||||
oninput="this.style.height = ''; this.style.height = this.scrollHeight + 'px'"
|
|
||||||
/>
|
|
||||||
<!-- if it works :3 -->
|
|
||||||
|
|
||||||
<!-- Details -->
|
|
||||||
<!-- <InfoView re={re} /> -->
|
|
||||||
|
|
||||||
<div class="flex flex-row align-middle items-center">
|
|
||||||
<p class="mt-4 text-[22pt] font-bold 'mt-4'">Ingredients</p>
|
|
||||||
<button class="hidden ml-auto mt-5 text-white bg-white/10 rounded-lg px-3 py-1 " id="add-ingredient-btn" >Add</button>
|
|
||||||
</div>
|
|
||||||
<table class={`table-fixed text-left bg-[#2a2b2c] rounded-lg w-full`}>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="px-4 py-2 w-18">Qty</th>
|
|
||||||
<th class="px-4 py-2 w-20">Unit</th>
|
|
||||||
<th class="px-4 py-2">Ingredient</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="ingredient-table" class="w-full border-t px-4 py-2 border-gray-600">
|
|
||||||
<tr id="ingredient-input" class="">
|
|
||||||
<td class="px-2 py-1">
|
|
||||||
<input id="ing-qty" class="w-full h-9 bg-white/10 rounded-lg px-2 py-2" type="text" placeholder="Qty">
|
|
||||||
</td>
|
|
||||||
<td class="px-2 py-1">
|
|
||||||
<input id="ing-unit" class="w-full h-9 bg-white/10 rounded-lg px-2 py-2" type="text" placeholder="Unit">
|
|
||||||
</td>
|
|
||||||
<td class="px-2 py-1">
|
|
||||||
<!-- <textarea id="ing-name" class="w-full h-11 bg-white/20 rounded-lg px-2 py-3 mt-1 resize-none leading-tight" placeholder="Ingredient" rows="1"/> -->
|
|
||||||
<input id="ing-name" class="w-full h-9 bg-white/10 rounded-lg px-2 py-2" type="text" placeholder="Ingredient">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ul class="flex mt-4 md:flex-2/3 w-full flex-col">
|
|
||||||
<!-- <p class="hidden md:block text-[28pt] font-bold pl-5">Helloi</p> -->
|
|
||||||
|
|
||||||
<!-- Steps -->
|
|
||||||
<p class="text-[22pt] font-bold md:hidden">Steps</p>
|
|
||||||
|
|
||||||
<div class="bg-[#2a2b2c] md:ml-3 rounded-lg mb-2 p-2">
|
|
||||||
<!-- <p class="text-bold text-[10pt]">Step</p> -->
|
|
||||||
<textarea
|
|
||||||
id="new-instruction"
|
|
||||||
class="bg-white/10 w-full h-full rounded-lg resize-none px-3 py-1"
|
|
||||||
placeholder="New Step"
|
|
||||||
oninput="this.style.height = ''; this.style.height = this.scrollHeight + 'px'"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</SiteLayout>
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
let ingredientFields: HTMLInputElement[] = []
|
|
||||||
let ingredientTable: HTMLTableSectionElement = document.querySelector('#ingredient-table')!
|
|
||||||
let ingredientAddButton: HTMLButtonElement = document.querySelector('#add-ingredient-btn')!
|
|
||||||
|
|
||||||
// - VARS
|
|
||||||
let ingredients: {qty: string, unit: string, name: string}[] = []
|
|
||||||
let steps: {
|
|
||||||
name: string,
|
|
||||||
description: string,
|
|
||||||
servings: number,
|
|
||||||
rating: number,
|
|
||||||
worktime: number,
|
|
||||||
waittime: number,
|
|
||||||
images: string[], // record ID of uploaded image
|
|
||||||
|
|
||||||
}[] = []
|
|
||||||
|
|
||||||
// - INIT
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
|
|
||||||
ingredientFields.push(
|
|
||||||
document.querySelector('#ing-qty')!,
|
|
||||||
document.querySelector('#ing-unit')!,
|
|
||||||
document.querySelector('#ing-name')!
|
|
||||||
)
|
|
||||||
|
|
||||||
// show plus button once the user clicks off one of the text fields
|
|
||||||
ingredientFields.forEach(f => f.addEventListener('beforeinput', showAddIngredientButton))
|
|
||||||
// onclick for add button
|
|
||||||
document.querySelector('#add-ingredient-btn')?.addEventListener('click', addIngredient);
|
|
||||||
// for pressing enter to reset cursor
|
|
||||||
ingredientFields[2].addEventListener('keyup', e => {if (e.key === 'Enter') addIngredient()} )
|
|
||||||
});
|
|
||||||
|
|
||||||
// - ADD
|
|
||||||
function addIngredient() {
|
|
||||||
const ing = {
|
|
||||||
qty: ingredientFields[0].value,
|
|
||||||
unit: ingredientFields[1].value,
|
|
||||||
name: ingredientFields[2].value
|
|
||||||
}
|
|
||||||
|
|
||||||
ingredients.push(ing)
|
|
||||||
|
|
||||||
const newRow = document.createElement('tr')
|
|
||||||
newRow.innerHTML = `
|
|
||||||
<td class="px-4 py-2 border-t border-white/10">${ing.qty}</td>
|
|
||||||
<td class="px-4 py-2 border-t border-white/10">${ing.unit}</td>
|
|
||||||
<td class="px-4 py-2 border-t border-white/10">${ing.name}</td>
|
|
||||||
`
|
|
||||||
|
|
||||||
// Add row to table and clear fields
|
|
||||||
ingredientTable.appendChild(newRow)
|
|
||||||
ingredientFields.forEach(f => f.value = '')
|
|
||||||
ingredientAddButton.style.display = 'none' // Hide Add Ingredient button
|
|
||||||
// move cursor to Qty field again
|
|
||||||
ingredientFields[0].focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
// - UTILS
|
|
||||||
function showAddIngredientButton() {
|
|
||||||
// only show if there is text in the field
|
|
||||||
|
|
||||||
if (ingredientFields[0].value && ingredientFields[2].value) {
|
|
||||||
ingredientAddButton.style.display = 'block'
|
|
||||||
} else {
|
|
||||||
ingredientAddButton.style.display = 'hidden'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"@/components/*": ["src/components/*.astro"],
|
"@/components/*": ["src/components/*.astro"],
|
||||||
"@/layouts/*": ["src/layouts/*.astro"],
|
"@/layouts/*": ["src/layouts/*.astro"],
|
||||||
"@/script/*": ["src/script/*"],
|
|
||||||
"@/utils": ["src/utils/index.ts"],
|
"@/utils": ["src/utils/index.ts"],
|
||||||
"@/data/*": ["src/data/*"],
|
"@/data/*": ["src/data/*"],
|
||||||
"@/site-config": ["src/site.config.ts"]
|
"@/site-config": ["src/site.config.ts"]
|
||||||
|
|||||||
Reference in New Issue
Block a user