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

Introducing i18n version of the app #55

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .env.example.en
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Example .env file for local development
# For production, environment variables are set on the production server

# SvelteKit settings
ORIGIN=http://localhost:5173

# PostOwl settings
DB_PATH="./data/db.sqlite3"
ADMIN_PASSWORD="your-secret-password"
ADMIN_NAME="Your Name"
ADMIN_EMAIL="[email protected]"
INITIAL_MESSAGE="Welcome to my PostOwl website!"

# SMTP settings for dev if using mailpit - see README for instructions
SMTP_SERVER="localhost"
SMTP_PORT="1025"
SMTP_USERNAME="postmaster@localhost" # can be whatever you want in dev
SMTP_PASSWORD="password" # can be whatever you want in dev
18 changes: 18 additions & 0 deletions .env.example.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Example .env file for local development
# For production, environment variables are set on the production server

# SvelteKit settings
ORIGIN=http://localhost:5173

# PostOwl settings
DB_PATH="./data/db.sqlite3"
ADMIN_PASSWORD="your-secret-password"
ADMIN_NAME="Twoja Nazwa"
ADMIN_EMAIL="[email protected]"
INITIAL_MESSAGE="Witamy na mojej stronie PostOwl!"

# SMTP settings for dev if using mailpit - see README for instructions
SMTP_SERVER="localhost"
SMTP_PORT="1025"
SMTP_USERNAME="postmaster@localhost" # can be whatever you want in dev
SMTP_PASSWORD="password" # can be whatever you want in dev
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.DS_Store
.env*
!.env.example
!.env.example.*
!.env.production.example
*.sqlite3*
.tool-versions
Expand Down
54 changes: 54 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# syntax = docker/dockerfile:1

ARG NODE_VERSION=20.11.1
FROM node:${NODE_VERSION}-slim AS base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y build-essential pkg-config python-is-python3

# Install node modules
COPY --link .npmrc package-lock.json package.json ./
RUN npm ci --include=dev

# Copy application code
COPY --link . .

# Build application
RUN mkdir /data && npm run build

# Remove development dependencies
RUN npm prune --omit=dev

# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y sqlite3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built application
COPY --from=build /app /app

# Setup sqlite3 on a separate volume
RUN mkdir -p /data
VOLUME /data
RUN chmod +x /app/scripts/create_sqlite.sh
RUN /app/scripts/create_sqlite.sh

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
ENV DATABASE_URL="file:///data/sqlite.db"
CMD [ "npm", "run", "start" ]
96 changes: 96 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"@sveltejs/adapter-auto": "^3.1.1",
"@sveltejs/kit": "^2.5.3",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@sveltekit-i18n/base": "^1.3.7",
"@sveltekit-i18n/parser-icu": "^1.0.8",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
Expand Down
5 changes: 5 additions & 0 deletions scripts/create_sqlite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FILE="./data/db.sqlite3"
if ! [ -f "$FILE" ]
then
sqlite3 $FILE < ./scripts/schema.sql
fi
1 change: 1 addition & 0 deletions src/hooks.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export async function handle({ event, resolve }) {
// ATTENTION: Never expose anything to event.locals that shouldn't be seen by the client
// We mix in ...local to data objects on server routes
event.locals.currentUser = await getCurrentUser(event.cookies.get('sessionid'));
console.log(`src/hooks.server.js: ${event.locals.currentUser?.name}`);
event.locals.bio = await getBio();
event.locals.counts = await getCounts();
event.locals.origin = event.url.origin;
Expand Down
Loading