[PIE-1] add api docker files
This commit is contained in:
parent
5b0a6561b0
commit
0c692a62e8
25
api/Dockerfile
Normal file
25
api/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
ARG PB_VERSION=0.29.2
|
||||||
|
ENV PB_DATA_DIR=/pb_data
|
||||||
|
|
||||||
|
WORKDIR /pb
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
unzip \
|
||||||
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
bash
|
||||||
|
|
||||||
|
# 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 entrypoint
|
||||||
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
CMD ["serve", "--http=0.0.0.0:8080"]
|
27
api/docker-entrypoint.sh
Normal file
27
api/docker-entrypoint.sh
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Required env-vars
|
||||||
|
: "${PB_ADMIN_EMAIL:?need PB_ADMIN_EMAIL}"
|
||||||
|
: "${PB_ADMIN_PASSWORD:?need PB_ADMIN_PASSWORD}"
|
||||||
|
: "${PB_DATA_DIR:?need PB_DATA_DIR}"
|
||||||
|
|
||||||
|
# ensure data dir exists (for embedded SQLite + migrations + files)
|
||||||
|
mkdir -p "${PB_DATA_DIR}"
|
||||||
|
export POCKETBASE_DATA_DIR="${PB_DATA_DIR}"
|
||||||
|
|
||||||
|
# if there are no users yet, create the superuser
|
||||||
|
# we check the sqlite file for any existing record in the users table
|
||||||
|
if [ ! -f "${PB_DATA_DIR}/pb_data.db" ] || ! \
|
||||||
|
sqlite3 "${PB_DATA_DIR}/pb_data.db" \
|
||||||
|
"SELECT id FROM users WHERE email='${PB_ADMIN_EMAIL}' LIMIT 1;" \
|
||||||
|
| grep -q .; then
|
||||||
|
|
||||||
|
echo ">>> Creating PocketBase superuser: ${PB_ADMIN_EMAIL}"
|
||||||
|
/pb/pocketbase superuser create "${PB_ADMIN_EMAIL}" "${PB_ADMIN_PASSWORD}"
|
||||||
|
else
|
||||||
|
echo ">>> Superuser ${PB_ADMIN_EMAIL} already exists, skipping creation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# exec the real pocketbase binary with any passed arguments
|
||||||
|
exec /pb/pocketbase "$@"
|
@ -4,3 +4,11 @@ services:
|
|||||||
env_file: .env
|
env_file: .env
|
||||||
ports:
|
ports:
|
||||||
- "4173:4173"
|
- "4173:4173"
|
||||||
|
|
||||||
|
pb:
|
||||||
|
build: api
|
||||||
|
env_file: .env
|
||||||
|
volumes:
|
||||||
|
- ./data:/pb_data
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
9
package-lock.json
generated
9
package-lock.json
generated
@ -7,6 +7,9 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "recipie",
|
"name": "recipie",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"dependencies": {
|
||||||
|
"pocketbase": "^0.26.2"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-node": "^5.2.12",
|
"@sveltejs/adapter-node": "^5.2.12",
|
||||||
"@sveltejs/kit": "^2.22.0",
|
"@sveltejs/kit": "^2.22.0",
|
||||||
@ -2084,6 +2087,12 @@
|
|||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/pocketbase": {
|
||||||
|
"version": "0.26.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.26.2.tgz",
|
||||||
|
"integrity": "sha512-WA8EOBc3QnSJh8rJ3iYoi9DmmPOMFIgVfAmIGux7wwruUEIzXgvrO4u0W2htfQjGIcyezJkdZOy5Xmh7SxAftw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.6",
|
"version": "8.5.6",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
||||||
|
@ -28,5 +28,8 @@
|
|||||||
"tailwindcss": "^4.0.0",
|
"tailwindcss": "^4.0.0",
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^5.0.0",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.0.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"pocketbase": "^0.26.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user