Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UID2_CSTG_BASE_URL="https://operator-integ.uidapi.com"
UID2_CSTG_SERVER_PUBLIC_KEY="UID2-X-I-MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEo+jcPlk8GWn3iG0R5Il2cbFQI9hR3TvHxaBUKHl5Vh+ugr+9uLMiXihka8To07ETFGghEifY96Hrpe5RnYko7Q=="
UID2_CSTG_SUBSCRIPTION_ID="DMr7uHxqLU"
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Set default behavior to automatically normalize line endings
* text=auto

# Shell scripts should use LF
*.sh text eol=lf

# Docker files should use LF
Dockerfile text eol=lf
docker-compose.yml text eol=lf

# Environment files can use CRLF on Windows
*.env text
env text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
.DS_Store
.env
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,64 @@ The example applications illustrate the basic steps that you need to consider fo
- Deal with missing identities.
- Handle user opt-outs.

## Docker Compose Setup

This repository includes Docker Compose configuration for easy development and testing of multiple UID2 integration examples.

### Quick Start

**Start all services:**
```bash
docker-compose up -d
```

**Start a single service:**
```bash
# Start only the Prebid.js client-side integration
docker-compose up -d prebid-client

# Start with live logs (foreground)
docker-compose up prebid-client
```

**Stop services:**
```bash
# Stop all services
docker-compose down

# Stop a single service
docker-compose stop prebid-client
```

**View logs:**
```bash
# View all logs
docker-compose logs -f

# View logs for a specific service
docker-compose logs -f prebid-client
```

**Rebuild and restart:**
```bash
# Rebuild and restart all services
docker-compose up -d --build

# Rebuild and restart a single service
docker-compose up -d --build prebid-client
```

### Available Services

- **`prebid-client`** - Prebid.js client-side integration (Port: 3031)
- *More services will be added as they are containerized*

### Environment Configuration

Edit the `.env` file in the base directory to configure your UID2 settings:
```
UID2_BASE_URL="http://localhost:8080"
SERVER_PUBLIC_KEY="your-public-key"
SUBSCRIPTION_ID="your-subscription-id"
```

27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3.8'

services:
prebid-client:
build:
context: .
dockerfile: web-integrations/prebid-integrations/client-side/Dockerfile
ports:
- "3031:3031"
container_name: prebid-client-side

# Add more services here as needed
# google-secure-signals-client:
# build:
# context: .
# dockerfile: web-integrations/google-secure-signals/client-side/Dockerfile
# ports:
# - "3032:3032"
# container_name: google-secure-signals-client

# javascript-sdk-client:
# build:
# context: .
# dockerfile: web-integrations/javascript-sdk/client-side/Dockerfile
# ports:
# - "3033:3033"
# container_name: javascript-sdk-client
1 change: 0 additions & 1 deletion web-integrations/prebid-integrations/client-side/.gitkeep

This file was deleted.

34 changes: 16 additions & 18 deletions web-integrations/prebid-integrations/client-side/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# Use nginx as the base image
FROM nginx:alpine

# Copy the static files to nginx html directory
COPY index.html /usr/share/nginx/html/
COPY app.css /usr/share/nginx/html/
COPY prebid.js /usr/share/nginx/html/
COPY config.js /usr/share/nginx/html/
# Install gettext for envsubst
RUN apk add --no-cache gettext

# Create custom nginx config to listen on port 3031
RUN echo 'server {' > /etc/nginx/conf.d/default.conf && \
echo ' listen 3031;' >> /etc/nginx/conf.d/default.conf && \
echo ' location / {' >> /etc/nginx/conf.d/default.conf && \
echo ' root /usr/share/nginx/html;' >> /etc/nginx/conf.d/default.conf && \
echo ' index index.html;' >> /etc/nginx/conf.d/default.conf && \
echo ' }' >> /etc/nginx/conf.d/default.conf && \
echo '}' >> /etc/nginx/conf.d/default.conf
# Copy the env file
COPY .env /tmp/env

# Expose port 3031
EXPOSE 3031
# Copy static files from client-side directory
COPY web-integrations/prebid-integrations/client-side/app.css /usr/share/nginx/html/
COPY web-integrations/prebid-integrations/client-side/prebid.js /usr/share/nginx/html/

# Start nginx
CMD ["nginx", "-g", "daemon off;"]
# Copy config and HTML
COPY web-integrations/prebid-integrations/client-side/default.conf /etc/nginx/conf.d/default.conf
COPY web-integrations/prebid-integrations/client-side/index.html /usr/share/nginx/html/index.template.html
COPY web-integrations/prebid-integrations/client-side/entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
19 changes: 9 additions & 10 deletions web-integrations/prebid-integrations/client-side/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ Then navigate to [http://localhost:3031](http://localhost:3031) to view the appl

### Local Development with Custom Settings

For local development, you can override the default settings by editing the `config.js` file:
The application automatically reads configuration from the `.env` file in the sample directory and substitutes the values into the HTML:

1. **Edit `config.js`** - Uncomment and modify the lines for your local environment:
```javascript
// Uncomment these lines in config.js:
window.UID2_BASE_URL = 'https://your-local-uid2-operator.com';
window.SERVER_PUBLIC_KEY = 'your-local-public-key';
window.SUBSCRIPTION_ID = 'your-local-subscription-id';
1. **Edit the `env` file** in the sample directory (`.env`) to set your local values:
```
UID2_BASE_URL="http://localhost:8080"
SERVER_PUBLIC_KEY="your-local-public-key"
SUBSCRIPTION_ID="your-local-subscription-id"
```

2. **Rebuild and run the Docker container:**
2. **Build and run the Docker container:**
```bash
docker build -t prebid-client-side .
docker run -p 3031:3031 prebid-client-side
Expand All @@ -41,10 +40,10 @@ For local development, you can override the default settings by editing the `con
3. **Alternative: Use browser dev tools** (for quick testing):
```javascript
// In browser console before page load
window.UID2_BASE_URL = 'https://your-local-uid2-operator.com';
window.uid2_example_settings.UID2_BASE_URL = 'https://your-local-uid2-operator.com';
```

The `config.js` file includes example configurations for different environments (local, test, staging).
The Docker build process automatically reads the `.env` file and substitutes the values into the HTML using `envsubst`. If a variable is not set in the `env` file, it uses the default values (after the `:-` in the substitution syntax).


## Prebid.js
Expand Down
7 changes: 0 additions & 7 deletions web-integrations/prebid-integrations/client-side/config.js

This file was deleted.

9 changes: 9 additions & 0 deletions web-integrations/prebid-integrations/client-side/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 3031;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ =404;
}
}
19 changes: 19 additions & 0 deletions web-integrations/prebid-integrations/client-side/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# Load environment variables from env file
export $(cat /tmp/env | xargs)

# Set default values if not provided
export BASE_URL=${UID2_CSTG_BASE_URL:-"https://operator-integ.uidapi.com"}
export SERVER_PUBLIC_KEY=${UID2_CSTG_SERVER_PUBLIC_KEY:-"UID2-X-I-MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEo+jcPlk8GWn3iG0R5Il2cbFQI9hR3TvHxaBUKHl5Vh+ugr+9uLMiXihka8To07ETFGghEifY96Hrpe5RnYko7Q=="}
export SUBSCRIPTION_ID=${UID2_CSTG_SUBSCRIPTION_ID:-"DMr7uHxqLU"}

# Copy static files
cp /usr/share/nginx/html/app.css /usr/share/nginx/html/
cp /usr/share/nginx/html/prebid.js /usr/share/nginx/html/

# Process index.html template with environment variables
envsubst < /usr/share/nginx/html/index.template.html > /usr/share/nginx/html/index.html

# Start nginx
exec nginx -g "daemon off;"
7 changes: 3 additions & 4 deletions web-integrations/prebid-integrations/client-side/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
<link rel="shortcut icon" href="/img/favicon.ico" />
<script async src="./prebid.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="./config.js"></script>
<script>
console.log('Initializing example.')
// Environment variables with defaults
window.uid2_example_settings = {
UID2_BASE_URL: window.UID2_BASE_URL || 'https://operator-integ.uidapi.com',
SERVER_PUBLIC_KEY: window.SERVER_PUBLIC_KEY || 'UID2-X-I-MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEo+jcPlk8GWn3iG0R5Il2cbFQI9hR3TvHxaBUKHl5Vh+ugr+9uLMiXihka8To07ETFGghEifY96Hrpe5RnYko7Q==',
SUBSCRIPTION_ID: window.SUBSCRIPTION_ID || 'DMr7uHxqLU',
UID2_BASE_URL: '${BASE_URL}',
SERVER_PUBLIC_KEY: '${SERVER_PUBLIC_KEY}',
SUBSCRIPTION_ID: '${SUBSCRIPTION_ID}',
};

function updateGuiElements() {
Expand Down