{"id":28245647,"url":"https://github.com/apilogicserver/docker-compose-nw-postgres","last_synced_at":"2025-06-14T19:31:42.742Z","repository":{"id":185966206,"uuid":"673901425","full_name":"ApiLogicServer/docker-compose-nw-postgres","owner":"ApiLogicServer","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-06T18:08:45.000Z","size":7333,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T09:12:58.747Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ApiLogicServer.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"security/__init__.py","support":null,"governance":null}},"created_at":"2023-08-02T17:22:09.000Z","updated_at":"2023-08-02T17:24:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"f40adfe3-b2df-482b-87dd-0fab66560ce6","html_url":"https://github.com/ApiLogicServer/docker-compose-nw-postgres","commit_stats":null,"previous_names":["apilogicserver/docker-compose-nw-postgres"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ApiLogicServer/docker-compose-nw-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApiLogicServer%2Fdocker-compose-nw-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApiLogicServer%2Fdocker-compose-nw-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApiLogicServer%2Fdocker-compose-nw-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApiLogicServer%2Fdocker-compose-nw-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ApiLogicServer","download_url":"https://codeload.github.com/ApiLogicServer/docker-compose-nw-postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApiLogicServer%2Fdocker-compose-nw-postgres/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259870690,"owners_count":22924579,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-19T09:12:57.421Z","updated_at":"2025-06-14T19:31:42.731Z","avatar_url":"https://github.com/ApiLogicServer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Postgres ApiLogicProject using Docker and docker-compose\n\nThis project illustrates using API Logic Server with Docker and docker-compose.  The objective is to provide a simple way to explore using docker with API Logic Server on your local machine.  These are *not* production procedures - they are designed for simple local machine operation.\n\nThe git project is an uncustomized API Logic Project created from the postgres Northwind database image.  This database is provided in a docker container:\n\n```bash\ndocker run -d --name postgresql-container --net dev-network -p 5432:5432 -e PGDATA=/pgdata -e POSTGRES_PASSWORD=p apilogicserver/postgres:latest\n```\n\nThis doc explains:\n\n* **I. Running the git project as an *image*** - acquire pre-created project from git, and run\n\n* **II. Running the git project as a *docker-compose*** - build, deploy and run\n\n* **III. Recreating the project** - how to rebuild the project from scratch\n\n* **IV. Status, Open Issues (eg, not working on windows)** \n\n\nWe presume you have Python,  `pip installed` ApiLogicServer (version \u003e= 09.01.25 - [preview here](https://apilogicserver.github.io/Docs/#preview-version)), and docker.\n\n\u0026nbsp;\n\n\u0026nbsp;\n\n# General Setup\n\nStop the docker-compose container, if it is running.\n\n\u0026nbsp;\n\n## 1. Install API Logic Server\n\nInstall the current (or [preview](https://apilogicserver.github.io/Docs/#preview-version)).  Use the `ApiLogicServer` command to verify the version note above.\n\n\u0026nbsp;\n\n## 2. Create the postgres database container:\n\nThe image contains not only Postgres, but also the `Northwind` and `authdb` databases.\n\n```bash\ndocker run -d --name postgresql-container --net dev-network -p 5432:5432 -e PGDATA=/pgdata -e POSTGRES_PASSWORD=p apilogicserver/postgres:latest\n```\n\n\u0026nbsp;\n\n## 3. Install this project from git\n\nFollow this procedure to obtain the *pre-created* project from git.\n\n```\n# git clone https://github.com/ApiLogicServer/docker-compose-nw-postgres.git\n# cd docker-compose-nw-postgres\n```\n\n\u0026nbsp;\n\n## 4. Verify local operation\n\nVerify proper installation:\n\n1. Open the project in VSCode\n\n2. Establish your (possibly preview) virtual environment\n\n3. Press F5 to run the server\n\n4. Run the [Admin App](http://localhost:5656), and Swagger\n\n\u0026nbsp;\n\n## Obtain the web app\n\nThe git project does not store these files, so you must obtain them:\n\n```bash\npushd devops/docker-compose\nsh install-webapp.sh\npopd\n```\n\n\u0026nbsp;\n\n\u0026nbsp;\n\n# I. Running the git project as image\n\n\u0026nbsp;\n\n## 1. Build the Image\n\n\u003e For preview versions, verify `devops/docker-image/build_image.dockerfile` is using `apilogicserver/api_logic_server_x` (note the *_x*).\n\n\u0026nbsp;\n\n```bash\ncd \u003cproject\u003e\nsh devops/docker-image/build_image.sh .\n```\n\n\u0026nbsp;\n\n## 2. Start the database\n\nFirst, if you haven't already done so, start the database:\n\n```bash\ndocker run -d --name postgresql-container --net dev-network -p 5432:5432 -e PGDATA=/pgdata -e POSTGRES_PASSWORD=p apilogicserver/postgres:latest\n```\n\n\u0026nbsp;\n\n## 3. Configure the server\n\nWhen run from a container, the database uri using `localhost` (from [ApiLogicServer create](#2-create-the-project)) does not work.  Observe the [`devops/docker-image/env.list`](devops/docker-image/env.list):\n\n```\nAPILOGICPROJECT_SQLALCHEMY_DATABASE_URI=postgresql://postgres:p@postgresql-container/postgres\nAPILOGICPROJECT_SQLALCHEMY_DATABASE_URI_AUTHENTICATION=postgresql://postgres:p@postgresql-container/authdb\n```\n\n\u0026nbsp;\n\n## 4. Start the Server\n\nUse the pre-created command line script:\n\n```bash\nsh devops/docker-image/run_image.sh\n```\n\n\u0026nbsp;\n\n## 5. Run the App\n\nRun the [Admin App](http://localhost:5656), and Swagger.\n\nYou can also run the [Authentication Administration App](http://localhost:5656/admin/authentication_admin/) to define users and roles (though not required).\n\n\u0026nbsp;\n\n\u0026nbsp;\n\n# II. Running the git project as docker-compose\n\n\u0026nbsp;\n\n## 1. Stop the docker database\n\nThe procedure below will spin up *another* database container.\n\nEnsure you are not already running the API Logic Server postgres database in a docker container.  If it's running, you will see port conflicts.\n\n\u0026nbsp;\n\n## 2. Build, Deploy and Run\n\nThe following will build, deploy and start the container stack locally:\n\n```\n# cd ./devops/docker-compose/\n# sh docker-compose.sh     # windows: .\\docker-compose.ps\n```\n\nThen, in your browser, open [`localhost`](http://localhost).\n\n\u0026nbsp;\n\n### Manual Port configuration\n\nIf that fails (e.g., windows), enter your port into [`devops/docker-image/docker-compose.yml`](./devops/docker-compose/docker-compose.yml).\n\nThen, use the following to build, deploy and start the default container stack locally:\n\n```\n# cd postgres-docker-compose  # \u003cproject-root\u003e\n# docker-compose -f ./devops/docker-compose/docker-compose.yml up\n```\n\nThen, in your browser, open [`localhost`](http://localhost).\n\n\u0026nbsp;\n\n## 3. Add Security\n\nThe postgres database contains `authdb`.  To activate security, update [`devops/docker-compose/docker-compose.yml`](devops/docker-compose/docker-compose.yml):\n\n1. Set `- SECURITY_ENABLED=true`\n\n2. Under api-logic-server-environment, observe:\n\n`          - APILOGICPROJECT_SQLALCHEMY_DATABASE_URI_AUTHENTICATION=postgresql://postgres:p@nw_postgres/authdb\n`\n\n\u0026nbsp;\n\n\u0026nbsp;\n\n# III. Recreating the Project\n\nAfter verifying project operation using the instructions above, you may wish to re-create the project from scratch.\n\nRe-create this project as follows:\n\n\u0026nbsp;\n\n## 0. Setup\n\nStop the docker-compose container, if it is running.\n\n\u0026nbsp;\n\n## 1. Start the postgres database container:\n\n```bash\ndocker run -d --name postgresql-container --net dev-network -p 5432:5432 -e PGDATA=/pgdata -e POSTGRES_PASSWORD=p apilogicserver/postgres:latest\n```\n\nVerify it looks like this:\n\n![Authdb](images/postgres-authdb.png)\n\n\n\u0026nbsp;\n\n## 2. Create the Project:\n\nCreate the project with API Logic Server in the directory indicted below, as a sibling of this project obtained from github:\n\n```bash\ncd \u003cparent folder to this project\u003e\nApiLogicServer create --project_name=rebuild-docker-compose-nw-postgres --db_url=postgresql://postgres:p@localhost/postgres\n```\n\n![Project Structure](images/docker-compose.png)\n\n\u0026nbsp;\n\n## 3. Verify proper operation\n\nThe project should be ready to run without customization:\n\n1. Open the project in VSCode\n\n2. Establish your (possibly preview) virtual environment\n\n3. Press F5 to run the server\n\n4. Run the [Admin App](http://localhost:5656), and Swagger\n\n\u0026nbsp;\n\n## 4. Add Security - using the terminal window inside VSCode:\n\n**Stop the server.**\n\nUsing the terminal window **inside VSCode:**\n\n```bash\nApiLogicServer add-auth --project_name=. --db_url=postgresql://postgres:p@localhost/authdb\n```\nRe-run the project (F5), observe you need to login.  Observe further that **u1** does not work - you need to use ***admin***.\n\n\u0026nbsp;\n\n## 5. Obtain the web app\n\nThe git project does not store these files, so you must obtain them:\n\n```bash\npushd devops/docker-compose\nsh install-webapp.sh\npopd\n```\n\nYou have now recreated the git project.  You should be able to execute the instructions at the [top of this page](#i-running-the-git-project-as-image).\n\n\u0026nbsp;\n\n\u0026nbsp;\n\n# IV. Status, Open Issues\n\nThis procedure has been validated on several computers, in all aspects described above.\n\n\u0026nbsp;\n\n## Production Considerations\n\nAs noted above, this project is provided to explore docker / API Logic Server in a simple, local environment.  Production considerations:\n\n1. Instead of building the app image, you might prefer to built it separately and use *that* in the docker-compose, e.g.\n\n```bash\nservices:\n    api_logic_project:\n        container_name: apilogicserver/docker-compose-nw\n        network_mode: dev-network\n        env_file:\n            - 'env.list'\n```\n\n2. Database data is **in the image** to simplify installs.  You would typically use volumes for data in production.\n\n\u0026nbsp;\n\n## Open Issues\n\nWe are investigating the following improvements (comments requested):\n\u0026nbsp;\n\n### 1. Not running under windows\n\nThe server builds, starts, and connects to the database.  The web app, however, fails to start in the browser.\n\n\u0026nbsp;\n\n### 2. `www/admin-app`\n\nThis is now obtained through an install step.  Please report issues / reactions.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapilogicserver%2Fdocker-compose-nw-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapilogicserver%2Fdocker-compose-nw-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapilogicserver%2Fdocker-compose-nw-postgres/lists"}