jiseki commited on
Commit
1b7bb7b
·
verified ·
1 Parent(s): c85a338

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -9
Dockerfile CHANGED
@@ -2,21 +2,39 @@ FROM alpine:latest
2
 
3
  ARG PB_VERSION=0.25.8
4
 
 
5
  RUN apk add --no-cache \
6
  unzip \
7
- ca-certificates
 
8
 
9
- # download and unzip PocketBase
10
- ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
11
- RUN unzip /tmp/pb.zip -d /pb/
12
 
13
- # uncomment to copy the local pb_migrations dir into the image
14
- # COPY ./pb_migrations /pb/pb_migrations
 
15
 
16
- # uncomment to copy the local pb_hooks dir into the image
17
- # COPY ./pb_hooks /pb/pb_hooks
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  EXPOSE 8080
20
 
21
- # start PocketBase
22
  CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8080"]
 
2
 
3
  ARG PB_VERSION=0.25.8
4
 
5
+ # Install required dependencies
6
  RUN apk add --no-cache \
7
  unzip \
8
+ ca-certificates \
9
+ shadow # Needed for useradd
10
 
11
+ # Set up a new user named "user" with user ID 1000
12
+ RUN useradd -m -u 1000 user
 
13
 
14
+ # Set home to the user's home directory
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH
17
 
18
+ # Set the working directory to the user's home directory
19
+ WORKDIR $HOME/app
20
+
21
+ # Create necessary directories with correct permissions
22
+ RUN mkdir -p $HOME/app /pb && chown -R user:user $HOME/app /pb
23
+
24
+ # Switch to the "user" user
25
+ USER user
26
+
27
+ # Download and unzip PocketBase, ensuring correct ownership
28
+ ADD --chown=user https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
29
+ RUN unzip /tmp/pb.zip -d /pb/ && rm /tmp/pb.zip
30
+
31
+ # Uncomment to copy the local pb_migrations dir into the image
32
+ # COPY --chown=user ./pb_migrations /pb/pb_migrations
33
+
34
+ # Uncomment to copy the local pb_hooks dir into the image
35
+ # COPY --chown=user ./pb_hooks /pb/pb_hooks
36
 
37
  EXPOSE 8080
38
 
39
+ # Start PocketBase
40
  CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8080"]