Skip to content

Commit

Permalink
stage 1 dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
rishikanthc committed Sep 27, 2024
1 parent b0ba1da commit 667ef02
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 118 deletions.
56 changes: 17 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,32 @@
# Use Node.js alpine as the base image
FROM node:18-alpine
FROM alpine:latest

ARG PB_VERSION=0.22.21
ARG [email protected]
ARG POCKETBASE_ADMIN_PASSWORD=admin123

RUN apk add --no-cache \
unzip \
ca-certificates
ca-certificates \
curl

# 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/

# Uncomment to copy the local pb_migrations dir into the image
# COPY ./pb_migrations /pb/pb_migrations

# Uncomment to copy the local pb_hooks dir into the image
# COPY ./pb_hooks /pb/pb_hooks

WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install SvelteKit dependencies
RUN npm install
# create PocketBase data directory
RUN mkdir -p /pb/pb_data
COPY start.sh /pb/start.sh

# Copy the rest of the SvelteKit app's source code
COPY . .
# start PocketBase in a background process to set up the database
RUN chmod +x /pb/start.sh

# Expose the PocketBase HTTP port
EXPOSE 8090 3000

# Copy the start.sh script into the container
COPY start.sh /start.sh

# Make the script executable
RUN chmod +x /start.sh

# Use the script to start PocketBase and create the admin user
RUN ["/bin/sh", "/start.sh"]

# Install supervisor
RUN apk add --no-cache supervisor
# uncomment to copy the local pb_migrations dir into the image
# COPY ./pb_migrations /pb/pb_migrations

# Copy supervisor configuration
COPY supervisord.conf /etc/supervisord.conf
# uncomment to copy the local pb_hooks dir into the image
# COPY ./pb_hooks /pb/pb_hooks

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
EXPOSE 8080

# CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8090", "--dev", "&&", "echo", "hello"]
# CMD echo "hello" & \
# /pb/pocketbase serve --http=0.0.0.0:8090 --dev & \
# /usr/local/bin/node build &
# start PocketBase
CMD ["/pb/start.sh"]
20 changes: 13 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
version: '3.8'

services:
app:
build:
context: .
sveltekit-pocketbase:
image: local-sveltekit-pocketbase:test
ports:
- "8090:8090" # SvelteKit app
- "3000:3000"
env_file:
- .env
- "8080:8080"
environment:
- POCKETBASE_URL=http://localhost:8080
- API_KEY=compose-runtime-key
- [email protected]
- POCKETBASE_ADMIN_PASSWORD=123
- TITLE=Compose Runtime App
volumes:
- ./pb_data:/app/pb_data
60 changes: 0 additions & 60 deletions src/hooks.server.ts

This file was deleted.

34 changes: 22 additions & 12 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { superValidate } from 'sveltekit-superforms';
import { formSchema } from '$lib/components/schema';
import { zod } from 'sveltekit-superforms/adapters';
import { TITLE } from '$env/static/private';
import { json } from "@sveltejs/kit";
import type { RequestHandler } from "./$types";
import { superValidate } from "sveltekit-superforms";
import { formSchema } from "$lib/components/schema";
import { zod } from "sveltekit-superforms/adapters";
import {
TITLE,
POCKETBASE_ADMIN_EMAIL,
POCKETBASE_ADMIN_PASSWORD,
} from "$env/static/private";

export async function load({ fetch, params }) {
const ftree = await fetch('/api/ls');
const tagresp = await fetch('/api/tags');
const tags = await tagresp.json();
const filetree = await ftree.json();
const siteTitle = TITLE;
const ftree = await fetch("/api/ls");
const tagresp = await fetch("/api/tags");
const tags = await tagresp.json();
const filetree = await ftree.json();
const siteTitle = TITLE;

return { filetree, siteTitle, tags };
console.log(
"logged in with: ",
POCKETBASE_ADMIN_EMAIL,
POCKETBASE_ADMIN_PASSWORD,
);

return { filetree, siteTitle, tags };
}

0 comments on commit 667ef02

Please sign in to comment.