-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Enhance developer experience with Docker and automation #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # --- Build Stage --- | ||
| FROM maven:3.9.6-eclipse-temurin-22 AS build | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /app | ||
|
|
||
| # Clone the Prebid Server Java repository | ||
| RUN git clone https://github.com/prebid/prebid-server-java.git . | ||
|
|
||
| # Build the project and create the executable JAR | ||
| RUN mvn clean package -Dmaven.test.skip=true | ||
|
|
||
| # --- Run Stage --- | ||
| FROM eclipse-temurin:22-jre-jammy | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy the JAR file from the build stage | ||
| COPY --from=build /app/target/prebid-server.jar . | ||
|
|
||
| # Copy the sample configuration file | ||
| COPY --from=build /app/sample/configs/prebid-config.yaml . | ||
|
|
||
| # Expose the port the application runs on | ||
| EXPOSE 8080 | ||
|
|
||
| # Set the entrypoint to run the application | ||
| ENTRYPOINT ["java", "-jar", "prebid-server.jar", "--spring.config.additional-location=prebid-config.yaml"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,78 +1,136 @@ | ||
| # prebid-server-java-walkthrough | ||
| A short walk through with scripts to help you get Prebid Server Java up and running. | ||
| # Prebid Server Java Walkthrough | ||
|
|
||
| ## Assumptions | ||
| Welcome to the Prebid Server Java Walkthrough! This guide provides a comprehensive set of instructions to help you get Prebid Server Java up and running on your local machine. Whether you prefer a manual setup, an automated script, or Docker, we've got you covered. | ||
|
|
||
| - Mac OS | ||
| - Java v22 | ||
| - Maven v3.9.6 | ||
| ## What is Prebid Server? | ||
|
|
||
| Prebid Server is an open-source solution that enables server-to-server header bidding, a programmatic advertising technique that allows publishers to simultaneously collect bids from multiple ad exchanges. By moving the auction to the server-side, Prebid Server reduces latency and improves the user experience on web pages and mobile apps. | ||
|
|
||
| This walkthrough focuses on the Java implementation of Prebid Server. | ||
|
|
||
| ## Directions | ||
| ## Table of Contents | ||
|
|
||
| 1. Install sdk man for managing the Java runtime. | ||
| - [Prerequisites](#prerequisites) | ||
| - [Setup Methods](#setup-methods) | ||
| - [1. Manual Setup](#1-manual-setup) | ||
| - [2. Automated Script Setup](#2-automated-script-setup) | ||
| - [3. Docker Setup](#3-docker-setup) | ||
| - [Testing Your Setup](#testing-your-setup) | ||
| - [Available Endpoints](#available-endpoints) | ||
|
|
||
| ``` | ||
| curl -s "https://get.sdkman.io" | bash | ||
| ``` | ||
| ## Prerequisites | ||
|
|
||
| 2. Install Java v22 | ||
| Before you begin, make sure you have the following tools installed on your system: | ||
|
|
||
| ``` | ||
| sdk install java 22.0.1-amzn | ||
| ``` | ||
| - **Git:** For cloning the repository. | ||
| - **cURL:** For testing the server endpoints. | ||
| - **Docker:** (Optional) If you choose the Docker-based setup. | ||
|
|
||
| 3. Make sure the Java v22 is the default Java runtime. | ||
| ## Setup Methods | ||
|
|
||
| ``` | ||
| sdk default java 22.0.1-amzn | ||
| ``` | ||
| Choose one of the following methods to set up Prebid Server Java. | ||
|
|
||
| 4. Install Maven v3.9.6 | ||
| --- | ||
|
|
||
| ``` | ||
| sdk install maven 3.9.6 | ||
| ``` | ||
| ### 1. Manual Setup | ||
|
|
||
| 5. Clone the Prebid Server Java repository. | ||
| This method walks you through the traditional process of setting up the server step-by-step. | ||
|
|
||
| ``` | ||
| git clone https://github.com/prebid/prebid-server-java.git | ||
| ``` | ||
| #### **Assumptions** | ||
| - You are using a macOS or Linux-based system. | ||
| - You have `sdkman` for managing Java and Maven versions. | ||
|
|
||
| 6. Navigate to the Prebid Server Java repository. | ||
| #### **Directions** | ||
|
|
||
| ``` | ||
| cd prebid-server-java | ||
| ``` | ||
| 1. **Install sdkman** for managing Java runtimes: | ||
| ```bash | ||
| curl -s "https://get.sdkman.io" | bash | ||
| ``` | ||
|
|
||
| 7. Build the Prebid Server Java project. | ||
| 2. **Install Java v22**: | ||
| ```bash | ||
| sdk install java 22.0.1-amzn | ||
| ``` | ||
|
|
||
| ``` | ||
| mvn clean package -Dmaven.test.skip=true | ||
| ``` | ||
| 3. **Set Java v22 as the default**: | ||
| ```bash | ||
| sdk default java 22.0.1-amzn | ||
| ``` | ||
|
|
||
| 8. Run the Prebid Server Java project. | ||
| 4. **Install Maven v3.9.6**: | ||
| ```bash | ||
| sdk install maven 3.9.6 | ||
| ``` | ||
|
|
||
| ``` | ||
| java -jar target/prebid-server.jar --spring.config.additional-location=sample/configs/prebid-config.yaml | ||
| ``` | ||
| 5. **Clone the Prebid Server Java repository**: | ||
| ```bash | ||
| git clone https://github.com/prebid/prebid-server-java.git | ||
| ``` | ||
|
|
||
| 9. Use CURL / Postman to test the Prebid Server Java project. | ||
| 6. **Navigate to the repository directory**: | ||
| ```bash | ||
| cd prebid-server-java | ||
| ``` | ||
|
|
||
| ``` | ||
| curl 'http://0.0.0.0:8080/status' | ||
| ``` | ||
| 7. **Build the project**: | ||
| ```bash | ||
| mvn clean package -Dmaven.test.skip=true | ||
| ``` | ||
|
|
||
| 8. **Run the server**: | ||
| ```bash | ||
| java -jar target/prebid-server.jar --spring.config.additional-location=sample/configs/prebid-config.yaml | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 2. Automated Script Setup | ||
|
|
||
| For a faster and more convenient setup, you can use the provided shell script to automate the entire process. | ||
|
|
||
| 1. **Make the script executable**: | ||
| ```bash | ||
| chmod +x setup.sh | ||
| ``` | ||
|
|
||
| 2. **Run the script**: | ||
| ```bash | ||
| ./setup.sh | ||
| ``` | ||
|
|
||
| The script will handle everything from installing dependencies to building and running the server. | ||
|
|
||
| --- | ||
|
|
||
| ### Endpoints Available for Testing | ||
| ### 3. Docker Setup | ||
|
|
||
| `/info/bidders` - Shows a list of bidders that are available to bid. | ||
| Containerize the application with Docker for a portable and isolated environment. This is the recommended approach for a hassle-free setup. | ||
|
|
||
| 1. **Build and run the container using Docker Compose**: | ||
| ```bash | ||
| docker-compose up --build | ||
| ``` | ||
|
|
||
| This command will build the Docker image and start the Prebid Server container. The server will be accessible at `http://localhost:8080`. | ||
|
|
||
| To stop the server, press `Ctrl+C`. | ||
|
|
||
| ## Testing Your Setup | ||
|
|
||
| Once the server is running, you can test its status by sending a request to the `/status` endpoint: | ||
|
|
||
| ```bash | ||
| curl 'http://0.0.0.0:8080/status' | ||
| ``` | ||
|
|
||
| `/info/bidders/33across` - Shows bid configurations for 33across. | ||
| If the server is running correctly, you should receive a response indicating its status. | ||
|
|
||
| `/openrtb2/auction` - Sends out bid request, receives bid responses. | ||
| ## Available Endpoints | ||
|
|
||
| `/cookie_sync` - Synchronizes cookies. | ||
| Here are some of the key endpoints you can use for testing and integration: | ||
|
|
||
| `/status` - Shows the status of the Prebid Server Java project. | ||
| - `/info/bidders`: Shows a list of available bidders. | ||
| - `/info/bidders/{bidder-name}`: Shows the configuration for a specific bidder (e.g., `/info/bidders/appnexus`). | ||
| - `/openrtb2/auction`: The primary endpoint for sending bid requests and receiving bid responses. | ||
| - `/cookie_sync`: Used for synchronizing user cookies with bidders. | ||
| - `/status`: Provides the current status of the Prebid Server. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| version: '3.8' | ||
|
|
||
| services: | ||
| prebid-server: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| ports: | ||
| - "8080:8080" | ||
| container_name: prebid-server-java | ||
| command: > | ||
| java -jar prebid-server.jar | ||
| --spring.config.additional-location=prebid-config.yaml | ||
| --server.port=8080 | ||
| --endpoints.status.port=8080 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,88 @@ | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| # Exit immediately if a command exits with a non-zero status. | ||||||
| set -e | ||||||
|
|
||||||
| # Function to check if a command exists | ||||||
| command_exists() { | ||||||
| command -v "$1" >/dev/null 2>&1 | ||||||
| } | ||||||
|
|
||||||
| # --- Introduction --- | ||||||
| echo "Welcome to the Prebid Server Java Automated Setup!" | ||||||
| echo "This script will guide you through the process of setting up and running the server." | ||||||
| echo "-----------------------------------------------------" | ||||||
|
|
||||||
| # --- Dependency Checks --- | ||||||
| echo "Checking for dependencies..." | ||||||
|
|
||||||
| if ! command_exists git; then | ||||||
| echo "Error: Git is not installed. Please install Git and try again." | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| if ! command_exists curl; then | ||||||
| echo "Error: cURL is not installed. Please install cURL and try again." | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| echo "All dependencies are satisfied." | ||||||
| echo "-----------------------------------------------------" | ||||||
|
|
||||||
| # --- SDKMAN, Java, and Maven Installation --- | ||||||
| echo "Setting up Java and Maven environment using sdkman..." | ||||||
|
|
||||||
| # Install sdkman if not already installed | ||||||
| if [ ! -d "$HOME/.sdkman" ]; then | ||||||
| echo "Installing sdkman..." | ||||||
| curl -s "https://get.sdkman.io" | bash | ||||||
| source "$HOME/.sdkman/bin/sdkman-init.sh" | ||||||
| else | ||||||
| echo "sdkman is already installed." | ||||||
| source "$HOME/.sdkman/bin/sdkman-init.sh" | ||||||
| fi | ||||||
|
|
||||||
| # Install Java and Maven | ||||||
| echo "Installing Java and Maven..." | ||||||
| sdk install java 22.0.1-amzn | ||||||
| sdk install maven 3.9.6 | ||||||
| sdk default java 22.0.1-amzn | ||||||
|
|
||||||
| echo "Java and Maven setup is complete." | ||||||
| echo "-----------------------------------------------------" | ||||||
|
|
||||||
| # --- Clone and Build Prebid Server --- | ||||||
| echo "Cloning the Prebid Server Java repository..." | ||||||
|
|
||||||
| if [ -d "prebid-server-java" ]; then | ||||||
| echo "prebid-server-java directory already exists. Skipping clone." | ||||||
| else | ||||||
| git clone https://github.com/prebid/prebid-server-java.git | ||||||
| fi | ||||||
|
|
||||||
| cd prebid-server-java | ||||||
|
|
||||||
| echo "Building the project with Maven... (This may take a few minutes)" | ||||||
| mvn clean package -Dmaven.test.skip=true | ||||||
|
|
||||||
| echo "Build complete." | ||||||
| echo "-----------------------------------------------------" | ||||||
|
|
||||||
| # --- Run Prebid Server --- | ||||||
| echo "Starting Prebid Server..." | ||||||
| java -jar target/prebid-server.jar --spring.config.additional-location=sample/configs/prebid-config.yaml & | ||||||
|
||||||
|
|
||||||
| # Give the server a moment to start | ||||||
| sleep 5 | ||||||
|
|
||||||
| # --- Verification --- | ||||||
| echo "Verifying server status..." | ||||||
| if curl -s 'http://0.0.0.0:8080/status' > /dev/null; then | ||||||
|
||||||
| if curl -s 'http://0.0.0.0:8080/status' > /dev/null; then | |
| if curl -s 'http://localhost:8080/status' > /dev/null; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
0.0.0.0in user-facing documentation is inconsistent with standard practices. Uselocalhostinstead for better clarity and consistency with typical local development workflows.