-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
53 lines (45 loc) · 1.53 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
# Stage 1: Build backend
FROM golang:1.23-alpine AS backend-builder
WORKDIR /build
COPY pocketbase/go.mod pocketbase/go.sum pocketbase/main.go ./
COPY pocketbase/pkg ./pkg
RUN apk --no-cache add upx make git gcc libtool musl-dev ca-certificates dumb-init \
&& go mod tidy \
&& CGO_ENABLED=0 go build \
&& upx one-click
# Stage 2: Build frontend
FROM node:lts-slim AS ui-builder
WORKDIR /build
COPY ./frontend/package*.json ./
RUN rm -rf ./node_modules ./build
COPY ./frontend .
ARG APP_VERSION=0.0.1
RUN echo "VITE_APP_VERSION=$APP_VERSION" > .env
RUN npm install --legacy-peer-deps
RUN npm run build
# Stage 3: Runtime
FROM alpine AS runtime
WORKDIR /app/one-click
# Install ca-certificates package and create directories
RUN apk --no-cache add ca-certificates \
&& mkdir -p /usr/local/share/ca-certificates \
&& mkdir -p /tmp/certs
# Copy application files
COPY --from=backend-builder /build/one-click /app/one-click/one-click
COPY ./pocketbase/pb_migrations ./pb_migrations
COPY --from=ui-builder /build/build /app/one-click/pb_public
# Create entrypoint script to handle certificates
COPY <<EOF /entrypoint.sh
#!/bin/sh
# If CUSTOM_CA_CERT environment variable is set, add the certificate
if [ -n "\${CUSTOM_CA_CERT}" ]; then
echo "\${CUSTOM_CA_CERT}" > /tmp/certs/custom-ca.crt
cp /tmp/certs/custom-ca.crt /usr/local/share/ca-certificates/
update-ca-certificates
fi
# Execute the main application
exec /app/one-click/one-click serve --http "0.0.0.0:8090"
EOF
RUN chmod +x /entrypoint.sh
EXPOSE 8090
ENTRYPOINT ["/entrypoint.sh"]