Resolved merge conflict using 'develop' changes
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ Click "Fork" on [GitHub](https://github.com/operacle/checkcle) to create your ow
|
|||||||
|
|
||||||
### 2. Clone Your Fork
|
### 2. Clone Your Fork
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/operacle/checkcle.git
|
git clone --branch develop https://github.com/operacle/checkcle.git
|
||||||
cd checkcle
|
cd checkcle
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
# Stage 1: Build the frontend
|
||||||
|
FROM node:18-alpine AS frontend-builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY application/package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY application/ ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Download PocketBase binary
|
||||||
|
FROM alpine:3.17 AS pb-builder
|
||||||
|
WORKDIR /pb
|
||||||
|
ARG PB_VERSION=0.27.2
|
||||||
|
RUN apk add --no-cache wget unzip \
|
||||||
|
&& wget https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip \
|
||||||
|
&& unzip pocketbase_${PB_VERSION}_linux_amd64.zip \
|
||||||
|
&& chmod +x /pb/pocketbase
|
||||||
|
|
||||||
|
# Stage 3: Final runtime image
|
||||||
|
FROM alpine:3.17
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy PocketBase binary
|
||||||
|
COPY --from=pb-builder /pb/pocketbase /app/pocketbase
|
||||||
|
|
||||||
|
# Copy frontend build to PocketBase public directory
|
||||||
|
COPY --from=frontend-builder /app/dist /app/pb_public
|
||||||
|
|
||||||
|
# Copy backend files
|
||||||
|
COPY server/pb_migrations /app/pb_migrations
|
||||||
|
COPY server/pb_data /app/pb_data
|
||||||
|
|
||||||
|
# Mark pb_data as a volume for runtime persistence
|
||||||
|
VOLUME /app/pb_data
|
||||||
|
|
||||||
|
# Expose default PocketBase port
|
||||||
|
EXPOSE 8090
|
||||||
|
|
||||||
|
# Launch PocketBase and bind to 0.0.0.0 for external access
|
||||||
|
CMD ["/app/pocketbase", "serve", "--http=0.0.0.0:8090", "--dir", "/app/pb_data"]
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
import PocketBase from 'pocketbase';
|
import PocketBase from 'pocketbase';
|
||||||
|
|
||||||
// Dynamically detect API base URL from current host (for use in browser)
|
// Auto-detect base URL from browser location
|
||||||
const dynamicBaseUrl =
|
const dynamicBaseUrl =
|
||||||
typeof window !== 'undefined'
|
typeof window !== 'undefined'
|
||||||
? `${window.location.protocol}//${window.location.hostname}:8090`
|
? window.location.origin
|
||||||
: 'http://localhost:8090';
|
: 'http://localhost:8090';
|
||||||
|
|
||||||
// Define available API endpoints
|
// Define API endpoints
|
||||||
export const API_ENDPOINTS = {
|
export const API_ENDPOINTS = {
|
||||||
REMOTE: dynamicBaseUrl
|
REMOTE: dynamicBaseUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the current endpoint from localStorage or use remote as default
|
|
||||||
export const getCurrentEndpoint = (): string => {
|
export const getCurrentEndpoint = (): string => {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
const savedEndpoint = localStorage.getItem('pocketbase_endpoint');
|
const savedEndpoint = localStorage.getItem('pocketbase_endpoint');
|
||||||
@@ -20,26 +19,19 @@ export const getCurrentEndpoint = (): string => {
|
|||||||
return API_ENDPOINTS.REMOTE;
|
return API_ENDPOINTS.REMOTE;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the API endpoint and reinitialize PocketBase
|
|
||||||
export const setApiEndpoint = (endpoint: string): void => {
|
export const setApiEndpoint = (endpoint: string): void => {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
localStorage.setItem('pocketbase_endpoint', endpoint);
|
localStorage.setItem('pocketbase_endpoint', endpoint);
|
||||||
window.location.reload(); // Reload to reinitialize PocketBase with new endpoint
|
window.location.reload();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize the PocketBase client with the current API URL
|
|
||||||
export const pb = new PocketBase(getCurrentEndpoint());
|
export const pb = new PocketBase(getCurrentEndpoint());
|
||||||
|
|
||||||
// Helper to check if user is authenticated
|
export const isAuthenticated = () => pb.authStore.isValid;
|
||||||
export const isAuthenticated = () => {
|
|
||||||
return pb.authStore.isValid;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Export the auth store for use in components
|
|
||||||
export const authStore = pb.authStore;
|
export const authStore = pb.authStore;
|
||||||
|
|
||||||
// Configure PocketBase to persist authentication between page reloads
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
const storedAuthData = localStorage.getItem('pocketbase_auth');
|
const storedAuthData = localStorage.getItem('pocketbase_auth');
|
||||||
if (storedAuthData) {
|
if (storedAuthData) {
|
||||||
@@ -52,13 +44,15 @@ if (typeof window !== 'undefined') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe to authStore changes to persist authentication
|
|
||||||
pb.authStore.onChange(() => {
|
pb.authStore.onChange(() => {
|
||||||
if (pb.authStore.isValid) {
|
if (pb.authStore.isValid) {
|
||||||
localStorage.setItem('pocketbase_auth', JSON.stringify({
|
localStorage.setItem(
|
||||||
token: pb.authStore.token,
|
'pocketbase_auth',
|
||||||
model: pb.authStore.model
|
JSON.stringify({
|
||||||
}));
|
token: pb.authStore.token,
|
||||||
|
model: pb.authStore.model
|
||||||
|
})
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem('pocketbase_auth');
|
localStorage.removeItem('pocketbase_auth');
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "checkcle-dev",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user