diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4eed4d4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,47 @@ +# Dependencies +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Development files +src/ +index.html +vite.config.js +*.md +.git/ +.gitignore + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Editor files +.vscode/ +.idea/ +*.swp +*.swo + +# Logs +logs +*.log + +# Environment files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# CI/CD +.forgejo/ +.github/ + +# Other +coverage/ +.nyc_output/ diff --git a/.forgejo/workflows/build-and-dockerise.yml b/.forgejo/workflows/build-and-dockerise.yml index 4eda5eb..c4bd873 100644 --- a/.forgejo/workflows/build-and-dockerise.yml +++ b/.forgejo/workflows/build-and-dockerise.yml @@ -26,12 +26,17 @@ jobs: with: fetch-depth: 0 # Recommended for metadata action - - name: Install pnpm dependencies - run: pnpm i + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install shell: sh - name: Build project - run: pnpm run build + run: bun run build shell: sh - name: Set up Docker Buildx diff --git a/Dockerfile b/Dockerfile index 13e67a6..3b99d41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,37 @@ -FROM nginx:latest +# Build stage +FROM oven/bun:latest as builder -COPY dist /usr/share/nginx/html -COPY entrypoint.sh /entrypoint.sh +WORKDIR /app -RUN chmod +x /entrypoint.sh +# Copy package files +COPY package.json bun.lock* ./ -ENTRYPOINT ["/entrypoint.sh"] +# Install all dependencies (including devDependencies for building) +RUN bun install --frozen-lockfile -STOPSIGNAL SIGQUIT -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +# Copy source code +COPY . . + +# Build the application +RUN bun run build + +# Production stage +FROM oven/bun:latest + +WORKDIR /app + +# Copy package files +COPY package.json bun.lock* ./ + +# Install only production dependencies +RUN bun install --frozen-lockfile --production + +# Copy built application and server +COPY --from=builder /app/dist ./dist +COPY src/server.ts ./src/server.ts + +# Expose the port +EXPOSE 3000 + +# Start the application +CMD ["bun", "run", "prod"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index e25a903..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# vim:sw=4:ts=4:et - -set -e - -entrypoint_log() { - if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then - echo "$@" - fi -} - -if [ "$1" = "nginx" ] || [ "$1" = "nginx-debug" ]; then - if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then - entrypoint_log "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" - - entrypoint_log "$0: Looking for shell scripts in /docker-entrypoint.d/" - find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do - case "$f" in - *.envsh) - if [ -x "$f" ]; then - entrypoint_log "$0: Sourcing $f"; - . "$f" - else - # warn on shell scripts without exec bit - entrypoint_log "$0: Ignoring $f, not executable"; - fi - ;; - *.sh) - if [ -x "$f" ]; then - entrypoint_log "$0: Launching $f"; - "$f" - else - # warn on shell scripts without exec bit - entrypoint_log "$0: Ignoring $f, not executable"; - fi - ;; - *) entrypoint_log "$0: Ignoring $f";; - esac - done - - entrypoint_log "$0: Configuration complete; ready for start up" - else - entrypoint_log "$0: No files found in /docker-entrypoint.d/, skipping configuration" - fi -fi - -# Check if the folder /extra exists, if so, copy all files from /extra to /usr/share/nginx/html -if [ -d "/extra" ]; then - echo "Copying files from /extra to /usr/share/nginx/html" - cp -r /extra/* /usr/share/nginx/html/ -fi - -echo "Executing command: $@" -exec "$@" \ No newline at end of file diff --git a/index.html b/index.html index ae1d96c..52ee898 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,6 @@ +
@@ -7,13 +8,14 @@ + - - + + @@ -29,19 +31,22 @@