prebid-server icon indicating copy to clipboard operation
prebid-server copied to clipboard

Hello World Sample

Open zhongshixi opened this issue 1 year ago • 25 comments

Change Set

  1. added an sample folder and introduces sample-as-code structure to demonstrate example usage with simple command for end user.

zhongshixi avatar Nov 28 '23 23:11 zhongshixi

@bretg here you go

zhongshixi avatar Nov 28 '23 23:11 zhongshixi

@shahinrahbariasl i would like to invite you to try out this initial sample and I am looking forward to your feedbacks

zhongshixi avatar Nov 28 '23 23:11 zhongshixi

@mkendall07

zhongshixi avatar Dec 01 '23 19:12 zhongshixi

@SyntaxNode , let me know if you have any opinion on it

zhongshixi avatar Dec 04 '23 21:12 zhongshixi

Hi @zhongshixi, thank you for the contribution! We discussed these changes with the team and have couple of suggestions. General idea is to have 2 options: set up PBS and run it

  1. from sources
  2. in Docker container.

This instruction is confusing because it will not work for the first option, for instance app.yaml should be pbs.yaml, stored responses should be placed under ./stored_responses/data/by_id/stored_responses and stored requests under ./stored_requests/data/by_id: "accounts", "stored_imps" and "stored_requests" directories. Instruction in this PR will work only for Docker container set up because it will copy files to the correct locations: https://github.com/prebid/prebid-server/pull/3326/files#:~:text=volumes%3A,bid%2Did.json It is confusing.

May you please add an instruction for the option 1 so users can distinct them and pick the one they need? It is partly described in the project root README.

We also think fetcher change should be a separate PR with unit tests, not a part of this PR. I also understand stored responses set up will not work without File System fetcher changes. Maybe fetcher PR should go first.

Question 1: why directory name is 001_banner? Question 2: do you think we can use simple docker run instead of docker compose up?

Proposed simplified steps to build and run PBS as a Docker container:

GOOS=linux GOARCH=amd64 go build -o ./build/prebid-server
docker build -f Dockerfile -t prebid-server .
docker run -d -p 8000:8000 prebid-server

Dockerfile:


FROM ubuntu:latest

RUN mkdir /app

COPY build/prebid-server /app

COPY static /app/static/
COPY stored_requests/data /app/stored_requests/data/
COPY stored_responses/data /app/stored_responses/data/
COPY pbs.yaml /app

WORKDIR /app

EXPOSE 8000
EXPOSE 6060
ENTRYPOINT ["/app/prebid-server"]

VeronikaSolovei9 avatar Dec 06 '23 01:12 VeronikaSolovei9

@VeronikaSolovei9 Thank you for your reply, I will answer your point 1 by 1

We also think fetcher change should be a separate PR with unit tests, not a part of this PR. I also understand stored responses setup will not work without File System fetcher changes. Maybe fetcher PR should go first.

I agree with you. For this, I will make it a separate PR.

Question 1: why the directory name is 001_banner?

@bretg and I discussed the direction of the sample regarding the sample file structure. The goal of the sample to provide a progressive learning/demo experience, that's why there is 001 indicates the first demo a user should see, then banner means the demo is to demo a banner ad, if the next material is related to video ads, then I can add 002_video as another example.

Question 2: do you think we can use a simple docker run instead of a docker compose-up?

we could use docker run, but I have a different opinion of docker run is simple. In my opinion, the docker-compose is just docker with flags and values written in the YAML file and uses the one-line command docker-compose up to bring up everything. If I use bare docker, I have to construct lengthy docker build, and docker run commands with so many flags and values which is not simple from my perspective. docker-compose is a one-stop shop for everything needed here. Maybe there is a reason not to use docker-compose at all?

Proposed simplified steps to build and run PBS as a Docker container:

I will experiment with it and let you know. The proposed solution does look simple but does require the user to build the go binrary on the host first, let me see what I can do to make it a one-command procedure.

May you please add an instruction for option 1 so users can distinct them and pick the one they need?
It is partly described in the project root README.

sure, let me figure something out

zhongshixi avatar Dec 06 '23 20:12 zhongshixi

This PR now also has some conflicts with master to resolve.

hhhjort avatar Mar 12 '24 17:03 hhhjort

We got a question to Prebid Support email that this PR would help resolve.

@hhhjort and @guscarreon - please take a look and merge?

bretg avatar Mar 20 '24 14:03 bretg

Hi @bretg Some time ago I left couple of comments related to Dockerfile, FileSystem Fetcher and general set up description. Should they be still addressed?

VeronikaSolovei9 avatar Mar 20 '24 19:03 VeronikaSolovei9

Some time ago I left couple of comments

Could you address these comments yourself @VeronikaSolovei9 ? @zhongshixi has abandoned this PR but I still need it if at all possible because we get newbies who have trouble getting started.

bretg avatar Mar 20 '24 19:03 bretg

@bretg @VeronikaSolovei9 sorry will you give you new commit & update ASAP next week, i am not abandoning this PR

zhongshixi avatar Mar 21 '24 17:03 zhongshixi

going to push something tonight

zhongshixi avatar Mar 27 '24 21:03 zhongshixi

Added minor suggestion. Local testing looks good, instruction makes sense. I like the idea using existing Dockerfile to build an image, rather than inventing a new one (I suggested it earlier :))

UPD: Please keep in mind that File fetcher PR should be merged first.

i also tried to append the instruction for users who wants to use source build instead of Dockerfile, but it complicates things because i need to basically copy the required sample files to the source folders , worry about deleting them later instead of using volume mounting which to me is a very clean approach, i suggest we keep the sample simple and later add support for user who is source-build heavy

zhongshixi avatar Apr 01 '24 13:04 zhongshixi

cc @bsardo for visibility

zhongshixi avatar Apr 02 '24 17:04 zhongshixi

@zhongshixi we merged your local stored response fetching PR and introduced a conflict here. Can you resolve when you get a moment? Thanks!

bsardo avatar Apr 10 '24 17:04 bsardo

@bsardo updated PR to resolve the conflict, testing looks good

Screenshot 2024-04-10 at 4 24 52 PM

cc @bretg for visibility

zhongshixi avatar Apr 10 '24 20:04 zhongshixi

Hi @zhongshixi, thank you for the updates. I tested this PR again and this is what I see: Screenshot 2024-04-11 at 12 56 38 PM

It worked before, but now something is not right

VeronikaSolovei9 avatar Apr 11 '24 19:04 VeronikaSolovei9

@VeronikaSolovei9 looking into it now to see what happened

zhongshixi avatar Apr 16 '24 13:04 zhongshixi

This should fix it: https://github.com/prebid/prebid-server/pull/3634

VeronikaSolovei9 avatar Apr 19 '24 00:04 VeronikaSolovei9

@VeronikaSolovei9 i saw the PR is closed - https://github.com/prebid/prebid-server/pull/3634#issuecomment-2070367928 which other place should i take a look for the corresponding fix?

zhongshixi avatar Apr 23 '24 14:04 zhongshixi

@zhongshixi I'll put up a PR shortly with the new fix and will ping you when it has been merged.

bsardo avatar Apr 23 '24 17:04 bsardo

@zhongshixi I merged in the fix (#3639) so hopefully that resolves any issues you were experiencing.

bsardo avatar Apr 25 '24 17:04 bsardo

going to merge from the latest master and try it again

zhongshixi avatar May 01 '24 20:05 zhongshixi

@bsardo thanks for the fix, it works again ( i have updated my branch to have the latest master branch code ) Screenshot 2024-05-03 at 11 16 01 AM

zhongshixi avatar May 03 '24 15:05 zhongshixi

@VeronikaSolovei9

docker compose build --no-cache

usually it is used to build the image completely from scratch, but you do not have to use it. The docker engine should be smart enough to understand if any layer of the image is changed.

take a look at the Dockerfile which contains COPY ./ ./ - so if you change any file in the repo that is not specified in .dockerignore when running docker-compose build , you should have a new image build.

maybe you are running a completely different private repo of the prebid server that is different from the open-sourced one which i do not have any visibility into. i can definitely help you if you could share more info about your environment

zhongshixi avatar May 08 '24 23:05 zhongshixi

@VeronikaSolovei9 no problem, thank you for all your feedbacks and review - excited about growing this tutorial module into a much more complete, matured, easy-to-use form in the future.

zhongshixi avatar May 17 '24 04:05 zhongshixi