init
This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.envrc
|
||||
.env
|
||||
*.env
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.envrc
|
||||
.env
|
||||
*.env
|
||||
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
||||
FROM alpine:latest
|
||||
|
||||
ARG PB_VERSION=0.30.0
|
||||
|
||||
LABEL maintainer="garandplg@garandplg.com"
|
||||
LABEL version="${PB_VERSION}"
|
||||
LABEL description="Pocketbase image"
|
||||
|
||||
RUN apk add --no-cache \
|
||||
unzip \
|
||||
ca-certificates
|
||||
|
||||
WORKDIR /pb
|
||||
|
||||
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 ./ \
|
||||
&& rm -rf \
|
||||
./CHANGELOG.md \
|
||||
./LICENSE.md \
|
||||
/tmp/pb.zip \
|
||||
/build \
|
||||
&& mkdir -p pb_data pb_public pb_migrations pb_hooks \
|
||||
&& chmod +x ./pocketbase \
|
||||
&& adduser -D pocketbase \
|
||||
&& chown -R pocketbase:pocketbase /pb
|
||||
|
||||
USER pocketbase
|
||||
|
||||
EXPOSE 8090
|
||||
|
||||
CMD ["./pocketbase", "serve", "--http", "0.0.0.0:8090", "--dir", "./pb_data", "--migrationsDir", "./pb_migrations", "--publicDir", "./pb_public", "--hooksDir", "./pb_hooks"]
|
||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1759036355,
|
||||
"narHash": "sha256-0m27AKv6ka+q270dw48KflE0LwQYrO7Fm4/2//KCVWg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e9f00bd893984bc8ce46c895c3bf7cac95331127",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
109
flake.nix
Normal file
109
flake.nix
Normal file
@@ -0,0 +1,109 @@
|
||||
{
|
||||
description = "PocketBase project with Docker";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
dockerfileContent = builtins.readFile ./Dockerfile;
|
||||
versionMatch = builtins.match ".*ARG PB_VERSION=([0-9]+\.[0-9]+\.[0-9]+).*" dockerfileContent;
|
||||
version = if versionMatch != null then builtins.head versionMatch else "latest";
|
||||
|
||||
registry = "gitea.garandplg.com";
|
||||
imageName = "garandplg/pocketbase";
|
||||
|
||||
pushScript = pkgs.writeShellScriptBin "push-images" ''
|
||||
set -e
|
||||
|
||||
if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ]; then
|
||||
echo "❌ Set DOCKER_USERNAME and DOCKER_PASSWORD environment variables"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🔐 Logging in to ${registry}..."
|
||||
echo "$DOCKER_PASSWORD" | docker login ${registry} -u "$DOCKER_USERNAME" --password-stdin
|
||||
|
||||
echo "🔨 Building Docker images with PocketBase version ${version}..."
|
||||
docker build -t ${registry}/${imageName}:${version} .
|
||||
docker tag ${registry}/${imageName}:${version} ${registry}/${imageName}:latest
|
||||
|
||||
echo "📤 Pushing ${registry}/${imageName}:${version}..."
|
||||
docker push ${registry}/${imageName}:${version}
|
||||
|
||||
echo "📤 Pushing ${registry}/${imageName}:latest..."
|
||||
docker push ${registry}/${imageName}:latest
|
||||
|
||||
echo "✅ Successfully pushed both images!"
|
||||
echo " - ${registry}/${imageName}:${version}"
|
||||
echo " - ${registry}/${imageName}:latest"
|
||||
'';
|
||||
|
||||
buildScript = pkgs.writeShellScriptBin "build-image" ''
|
||||
set -e
|
||||
|
||||
echo "🔨 Building PocketBase Docker image (version ${version})..."
|
||||
docker build -t ${registry}/${imageName}:${version} .
|
||||
docker tag ${registry}/${imageName}:${version} ${registry}/${imageName}:latest
|
||||
|
||||
echo "✅ Successfully built image!"
|
||||
echo " - ${registry}/${imageName}:${version}"
|
||||
echo " - ${registry}/${imageName}:latest"
|
||||
|
||||
echo "🚀 To run the container:"
|
||||
echo " docker run -p 8090:8090 ${registry}/${imageName}:latest"
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
docker
|
||||
direnv
|
||||
pushScript
|
||||
buildScript
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "🗃️ PocketBase + Docker environment"
|
||||
echo "📦 Detected PocketBase version: ${version}"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " build-image - Build Docker image locally"
|
||||
echo " push-images - Build and push to registry"
|
||||
echo ""
|
||||
echo "Environment variables needed for push:"
|
||||
echo " DOCKER_USERNAME - Your registry username"
|
||||
echo " DOCKER_PASSWORD - Your registry password/token"
|
||||
'';
|
||||
};
|
||||
|
||||
packages = {
|
||||
push-images = pushScript;
|
||||
build-image = buildScript;
|
||||
};
|
||||
|
||||
apps = {
|
||||
push = {
|
||||
type = "app";
|
||||
program = "${pushScript}/bin/push-images";
|
||||
};
|
||||
build = {
|
||||
type = "app";
|
||||
program = "${buildScript}/bin/build-image";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user