PageSourceSearch

https://bucketeer.io/assets/js/d6665858.e9acc5a0.js

js bucketeer.io collected 2026-10-04 21:03:14 UTC 16,139 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[2509],{4148:e=>{e.exports=JSON.parse('{"permalink":"/blog/developing-bucketeer-in-devcontainer","source":"@site/blog/2024/2024-12-18-developing-bucketeer-in-devcontainer.md","title":"Developing Bucketeer in DevContainer","description":"This blog post will guide you through the process of setting up a development environment for Bucketeer using a dev container. A dev container provides a consistent and isolated environment, ensuring that all developers have the necessary tools and dependencies to build and run the project.","date":"2024-12-18T12:00:00.000Z","tags":[{"inline":true,"label":"devcontainer","permalink":"/blog/tags/devcontainer"},{"inline":true,"label":"development","permalink":"/blog/tags/development"},{"inline":true,"label":"bucketeer","permalink":"/blog/tags/bucketeer"}],"readingTime":5.53,"hasTruncateMarker":true,"authors":[{"name":"Kenta Kozuka","title":"Software Engineer","url":"https://github.com/kentakozuka","page":{"permalink":"/blog/authors/kenta-kozuka"},"socials":{"github":"https://github.com/kentakozuka"},"imageURL":"/img/members/kenta-kozuka.png","key":"kenta-kozuka"}],"frontMatter":{"title":"Developing Bucketeer in DevContainer","slug":"developing-bucketeer-in-devcontainer","authors":["kenta-kozuka"],"tags":["devcontainer","development","bucketeer"],"hide_table_of_contents":false,"date":"2024-12-18T12:00"},"unlisted":false,"prevItem":{"title":"Flag Targeting Depending on Other Flags","permalink":"/blog/flag-targeting-depending-on-other-flags"},"nextItem":{"title":"Announcing Bucketeer 1.0","permalink":"/blog/announcing-bucketeer-1"}}')},28453:(e,n,t)=>{t.d(n,{RP:()=>r,xA:()=>a});var s=t(96540);const i=s.createContext({});function r(e){const n=s.useContext(i);return s.useMemo((()=>"function"==typeof e?e(n):{...n,...e}),[n,e])}const o={};function a({components:e,children:n,disableParentContext:t}){let a;return a=t?"function"==typeof e?e({}):e||o:r(e),s.createElement(i.Provider,{value:a},n)}},45129:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>l});var s=t(4148),i=t(74848),r=t(28453);const o={title:"Developing Bucketeer in DevContainer",slug:"developing-bucketeer-in-devcontainer",authors:["kenta-kozuka"],tags:["devcontainer","development","bucketeer"],hide_table_of_contents:!1,date:"2024-12-18T12:00"},a=void 0,c={authorsImageUrls:[void 0]},l=[{value:"Why Use a Dev Container?",id:"why-use-a-dev-container",level:3},{value:"Setting up the Dev Container",id:"setting-up-the-dev-container",level:3},{value:"Option 1: Using GitHub Codespaces",id:"option-1-using-github-codespaces",level:4},{value:"Option 2: Building Locally with VS Code",id:"option-2-building-locally-with-vs-code",level:4},{value:"Setting up Minikube and Services",id:"setting-up-minikube-and-services",level:3},{value:"Deploying Bucketeer",id:"deploying-bucketeer",level:3},{value:"Running E2E Tests",id:"running-e2e-tests",level:3},{value:"Database Schema Migrations",id:"database-schema-migrations",level:3},{value:"Customize your own dev container",id:"customize-your-own-dev-container",level:3},{value:"Conclusion",id:"conclusion",level:3}];function d(e){const n={a:"a",code:"code",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.RP)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.p,{children:"This blog post will guide you through the process of setting up a development environment for Bucketeer using a dev container. A dev container provides a consistent and isolated environment, ensuring that all developers have the necessary tools and dependencies to build and run the project."}),"\n",(0,i.jsx)(n.h3,{id:"why-use-a-dev-container",children:"Why Use a Dev Container?"}),"\n",(0,i.jsx)(n.p,{children:"Dev containers offer several advantages, including:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Consistency:"}),' Everyone on the team works in the same environment, reducing "it works on my machine" issues.']}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Isolation:"})," Project dependencies are isolated from your local system, avoiding conflicts."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ease of Setup:"})," The environment can be quickly set up, saving time and effort."]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"setting-up-the-dev-container",children:"Setting up the Dev Container"}),"\n",(0,i.jsx)(n.p,{children:"There are two main ways to set up the development environment using a dev container:"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Using GitHub Codespaces:"})," This is the easiest method, where the dev container runs directly in the cloud."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Building Locally with VS Code:"})," You can also build the dev container locally using the VS Code Dev Containers extension."]}),"\n"]}),"\n",(0,i.jsx)(n.h4,{id:"option-1-using-github-codespaces",children:"Option 1: Using GitHub Codespaces"}),"\n",(0,i.jsx)(n.p,{children:"This is the quickest way to start developing."}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Navigate to the Bucketeer project on GitHub."}),"\n",(0,i.jsxs)(n.li,{children:["Click the ",(0,i.jsx)(n.strong,{children:"Code"})," button and select ",(0,i.jsx)(n.strong,{children:"Codespaces"}),"."]}),"\n",(0,i.jsxs)(n.li,{children:["Click ",(0,i.jsx)(n.strong,{children:"Create codespace on main"}),"."]}),"\n",(0,i.jsx)(n.li,{children:"Wait for the dev container to be ready."}),"\n"]}),"\n",(0,i.jsx)(n.h4,{id:"option-2-building-locally-with-vs-code",children:"Option 2: Building Locally with VS Code"}),"\n",(0,i.jsx)(n.p,{children:"This option requires that you have VS Code and the Dev Containers extension installed."}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Clone the Bucketeer repository to your local machine."}),"\n",(0,i.jsx)(n.li,{children:"Open the project folder in VS Code."}),"\n",(0,i.jsx)(n.li,{children:'VS Code should prompt you to open the project in a dev container or you can use the command palette and select "Reopen in Container".'}),"\n",(0,i.jsxs)(n.li,{children:["The dev container is defined by the ",(0,i.jsx)(n.strong,{children:"devcontainer.json"})," file located in the ",(0,i.jsx)(n.strong,{children:".devcontainer"})," directory."]}),"\n",(0,i.jsx)(n.li,{children:"The file specifies the base image, customizations such as VS Code settings and extensions, host requirements such as CPUs, memory, and storage, and commands to run after the container is created."}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"setting-up-minikube-and-services",children:"Setting up Minikube and Services"}),"\n",(0,i.jsx)(n.p,{children:"Once your dev container is up and running, you need to set up Minikube and the services that Bucketeer depends on."}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["Use the command ",(0,i.jsx)(n.code,{children:"make start-minikube"})," to set up Minikube and the required services. This may take some time because it set up MySQL, Redis, Google Pub/Sub Emulator, and Google Big Query Emulator."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Important:"})," Always use ",(0,i.jsx)(n.code,{children:"make start-minikube"})," to start the Minikube cluster, not ",(0,i.jsx)(n.code,{children:"minikube start"})," directly."]}),"\n",(0,i.jsxs)(n.li,{children:["This command adds two hosts to ",(0,i.jsx)(n.code,{children:"/etc/hosts"})," which point to the minikube IP address for API Gateway and Web Gateway services. It also creates tables for MySQL and Google Big Query Emulator."]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"deploying-bucketeer",children:"Deploying Bucketeer"}),"\n",(0,i.jsx)(n.p,{children:"To deploy Bucketeer, use the following command:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"make deploy-bucketeer\n"})}),"\n",(0,i.jsx)(n.p,{children:"This command will deploy all the Bucketeer services at once. You can deploy single services by using helm install c
1ommands.\r\nNow you can see all pods are ready to go!"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"kubectl get pod\r\nNAME                                                          READY   STATUS      RESTARTS   AGE\r\napi-765bc5b867-58hfg                                          2/2     Running     0          2m14s\r\nbatch-server-7b48d58d57-vpzgp                                 3/3     Running     0          2m15s\r\nbatch-server-api-key-cacher-28908288-kllwh                    0/1     Completed   0          33s\r\nbatch-server-auto-ops-rules-cacher-28908288-289r8             0/1     Completed   0          24s\r\nbatch-server-experiment-cacher-28908288-z2qm9                 0/1     Completed   0          26s\r\nbatch-server-experiment-calculator-28908288-dzghs             0/1     Completed   0          35s\r\nbatch-server-experiment-status-updater-28908288-9lgvd         0/1     Completed   0          31s\r\nbatch-server-feature-flag-cacher-28908288-kcdcl               0/1     Completed   0          22s\r\nbatch-server-ops-datetime-watcher-28908288-rt2jf              0/1     Completed   0          42s\r\nbatch-server-ops-event-count-watcher-28908288-vmrpl           0/1     Completed   0          29s\r\nbatch-server-ops-progressive-rollout-watcher-28908288-zczfr   0/1     Completed   0          39s\r\nbatch-server-segment-user-cacher-28908288-7nrk5               0/1     Completed   0          37s\r\nbucketeer-migrate-ctpl6                                       0/1     Completed   0          2m22s\r\nlocalenv-bq-76d9485d5b-s8kkb                                  1/1     Running     0          10m\r\nlocalenv-mysql-0                                              1/1     Running     0          10m\r\nlocalenv-pubsub-5f4589c4b9-sc8vt                              1/1     Running     0          10m\r\nlocalenv-redis-master-0                                       1/1     Running     0          10m\r\nlocalenv-vault-0                                              1/1     Running     0          10m\r\nlocalenv-vault-agent-injector-7dd8f7998-rdntt                 1/1     Running     0          10m\r\nsubscriber-5cc47d5559-8b848                                   2/2     Running     0          2m15s\r\nweb-6c9d9cc5ff-ltzr9                                          2/2     Running     0          2m15s\n"})}),"\n",(0,i.jsx)(n.h3,{id:"running-e2e-tests",children:"Running E2E Tests"}),"\n",(0,i.jsx)(n.p,{children:"Before running end-to-end tests, you must create API keys for the Server and Client SDKs, which only need to be created once."}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"To create API Keys, use the following commands, updating names as needed:"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:'WEB_GATEWAY_URL=web-gateway.bucketeer.io \\\r\nWEB_GATEWAY_CERT_PATH=/workspaces/bucketeer/tools/dev/cert/tls.crt \\\r\nSERVICE_TOKEN_PATH=/workspaces/bucketeer/tools/dev/cert/service-token \\\r\nAPI_KEY_NAME="e2e-test-$(date +%s)-client" \\\r\nAPI_KEY_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_client \\\r\nAPI_KEY_ROLE=SDK_CLIENT \\\r\nENVIRONMENT_NAMESPACE=e2e \\\r\nmake create-api-key\r\n\r\nWEB_GATEWAY_URL=web-gateway.bucketeer.io \\\r\nWEB_GATEWAY_CERT_PATH=/workspaces/bucketeer/tools/dev/cert/tls.crt \\\r\nSERVICE_TOKEN_PATH=/workspaces/bucketeer/tools/dev/cert/service-token \\\r\nAPI_KEY_NAME="e2e-test-$(date +%s)-server" \\\r\nAPI_KEY_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_server \\\r\nAPI_KEY_ROLE=SDK_SERVER \\\r\nENVIRONMENT_NAMESPACE=e2e \\\r\nmake create-api-key\n'})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"To run the E2E tests, use the following command:"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"WEB_GATEWAY_URL=web-gateway.bucketeer.io \\\r\nGATEWAY_URL=api-gateway.bucketeer.io \\\r\nWEB_GATEWAY_CERT_PATH=/workspaces/bucketeer/tools/dev/cert/tls.crt \\\r\nGATEWAY_CERT_PATH=/workspaces/bucketeer/tools/dev/cert/tls.crt \\\r\nSERVICE_TOKEN_PATH=/workspaces
1/bucketeer/tools/dev/cert/service-token \\\r\nAPI_KEY_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_client \\\r\nAPI_KEY_SERVER_PATH=/workspaces/bucketeer/tools/dev/cert/api_key_server \\\r\nENVIRONMENT_NAMESPACE=e2e \\\r\nmake e2e\n"})}),"\n",(0,i.jsx)(n.h3,{id:"database-schema-migrations",children:"Database Schema Migrations"}),"\n",(0,i.jsx)(n.p,{children:"Bucketeer uses the Atlas tool for database schema migrations. The migrations run automatically when you install the Bucketeer Helm application, and if any migration fails, the application will not install."}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["To create migration files, you must port-forward the localenv-mysql service with ",(0,i.jsx)(n.code,{children:"kubectl port-forward svc/localenv-mysql 3306:3306"}),"."]}),"\n",(0,i.jsxs)(n.li,{children:["Then, use the command ",(0,i.jsx)(n.code,{children:"make create-migration NAME=<MIGRATION_FILE_NAME> HOST=localhost USER=bucketeer PASS=bucketeer PORT=3306 DB=bucketeer"}),"."]}),"\n",(0,i.jsxs)(n.li,{children:["Migration file names should have specific prefixes such as:","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"create:"})," For new tables (e.g., ",(0,i.jsx)(n.code,{children:"create_users_table"}),")."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"update:"})," For altering existing tables (e.g., ",(0,i.jsx)(n.code,{children:"update_users_table"}),")."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"drop:"})," For dropping tables (e.g., ",(0,i.jsx)(n.code,{children:"drop_users_table"}),")."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"If no structure changes were executed, you can create a migration file manually."}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"customize-your-own-dev-container",children:"Customize your own dev container"}),"\n",(0,i.jsx)(n.p,{children:"You can customize your dev container. For instance;"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Run SSH agent in your host machine to authenticate commands in dev container."}),"\n",(0,i.jsx)(n.li,{children:"Download your dotfiles when the dev container starts to run."}),"\n",(0,i.jsx)(n.li,{children:"Sync VSCode settings in Codespace."}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"Please check the following links to do those things."}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials",children:"https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://code.visualstudio.com/docs/devcontainers/containers#_personalizing-with-dotfile-repositories",children:"https://code.visualstudio.com/docs/devcontainers/containers#_personalizing-with-dotfile-repositories"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://docs.github.com/ja/codespaces/setting-your-user-preferences/personalizing-github-codespaces-for-your-account",children:"https://docs.github.com/ja/codespaces/setting-your-user-preferences/personalizing-github-codespaces-for-your-account"})}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"conclusion",children:"Conclusion"}),"\n",(0,i.jsx)(n.p,{children:"Developing Bucketeer inside a dev container provides a streamlined and consistent development experience. By following these steps, you can quickly set up your environment, build and deploy Bucketeer, and run tests effectively. This approach not only ensures a smooth development process but also helps in maintaining a reliable and efficient workflow. Let's develop Bucketeer together!"})]})}function u(e={}){const{wrapper:n}={...(0,r.RP)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.