-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
81 lines (65 loc) · 3.09 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
FROM --platform=${BUILDPLATFORM} alpine:3.18
ARG TARGETPLATFORM
ARG TARGETARCH=${TARGETARCH}
ARG TARGETOS=${TARGETOS}
ARG TARGETVARIANT=${TARGETVARIANT}
ARG BUILDPLATFORM=${BUILDPLATFORM}
ARG TZ=UTC
ARG PB_VERSION=0.21.3
ARG PB_ENCRYPTION_KEY
ARG PB_DEBUG
ARG PB_HOST=0.0.0.0
ARG PB_PORT=8181
ARG PB_CORS
ARG PB_DATA_DIR=/pb_data/database
ARG PB_MIGRATION_DIR=/pb_data/migration
ARG PB_PUBLIC_DIR=/pb_data/static
ARG PB_ULIMIT_OPEN_FILES=1024
ENV TZ="${TZ:-UTC}"
ENV POCKETBASE_VERSION="${PB_VERSION:-0.21.3}" \
POCKETBASE_ENCRYPTION_KEY="${PB_ENCRYPTION_KEY}" \
POCKETBASE_DATA_DIR="${PB_DATA_DIR:-/pb_data/database}" \
POCKETBASE_MIGRATION_DIR="${PB_MIGRATION_DIR:-/pb_data/migration}" \
POCKETBASE_PUBLIC_DIR="${PB_PUBLIC_DIR:-/pb_data/static}" \
POCKETBASE_DEBUG="${PB_DEBUG}" \
POCKETBASE_HOST="${PB_HOST}" \
POCKETBASE_PORT="${PB_PORT}" \
POCKETBASE_CORS="${PB_CORS}" \
POCKETBASE_ULIMIT_OPEN_FILES="${PB_ULIMIT_OPEN_FILES:-1024}"
RUN POCKETBASE_ENCRYPTION_KEY="$(echo -n $RANDOM | sha1sum | awk '{print $1}')"
RUN export POCKETBASE_ENCRYPTION_KEY
RUN echo "WARNING: POCKETBASE ENCRYPTION_KEY variable was not set or was not string!"
RUN echo "Secret key was automatically generated: ${POCKETBASE_ENCRYPTION_KEY}"
RUN echo "Please note down this value and set the POCKETBASE_ENCRYPTION_KEY within your deployment to avoid loosing access to your data!"
ENV PB_RELEASE_URL=https://github.com/pocketbase/pocketbase/releases/download
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
wget ${PB_RELEASE_URL}/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip -O /tmp/pocketbase.zip ; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
wget ${PB_RELEASE_URL}/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_arm64.zip -O /tmp/pocketbase.zip ; \
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
wget ${PB_RELEASE_URL}/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_armv7.zip -O /tmp/pocketbase.zip ; \
elif [ "$TARGETPLATFORM" = "linux/arm/v6" ]; then \
wget ${PB_RELEASE_URL}/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_arm64.zip -O /tmp/pocketbase.zip ; \
elif [ "$TARGETPLATFORM" = "darwin/amd64" ]; then \
wget ${PB_RELEASE_URL}/v${PB_VERSION}/pocketbase_${PB_VERSION}_darwin_amd64.zip -O /tmp/pocketbase.zip ; \
fi
RUN apk update && apk --no-cache --upgrade add tzdata \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
RUN apk add --no-cache \
ca-certificates \
unzip \
wget \
zip \
zlib-dev \
bash
RUN mkdir -p /tmp/pocketbase \
&& cd /tmp && unzip /tmp/pocketbase.zip -d /tmp/pocketbase \
&& cp /tmp/pocketbase/pocketbase /usr/bin/pocketbase \
&& rm -rf /tmp/pocketbase /tmp/pocketbase.zip \
&& chmod +x /usr/bin/pocketbase
RUN mkdir pb_data
RUN echo "ulimit open files => $PB_ULIMIT_OPEN_FILES"
RUN ulimit -n ${PB_ULIMIT_OPEN_FILES}
EXPOSE ${PB_PORT}
ENTRYPOINT pocketbase serve --http=${POCKETBASE_HOST}:${POCKETBASE_PORT} --encryptionEnv=${POCKETBASE_ENCRYPTION_KEY} --dir=${POCKETBASE_DATA_DIR} --migrationsDir=${POCKETBASE_MIGRATION_DIR} --publicDir=${POCKETBASE_PUBLIC_DIR}