Skip to content

swagger docker-compose instant openapi #989

Open
@nik2208

Description

@nik2208
Contributor

working on a project I prepared a docker-compose file to put up mysql, php, and swagger to work straight away on the php-crud-api endpoint.

this is what I ended up with:
docker-compose.yml

version: "3.9"
services:
  swagger:
    container_name: php-crud-api-swagger
    image: swaggerapi/swagger-ui
    restart: always
    environment:
      SWAGGER_JSON_URL: <url_to_php_crud_api_endpoint>
      DOC_EXPANSION: none # optionally set to list, or full

I've also have a repo available involving mysql, nginx, php-fpm and swagger to be up and running in seconds

Activity

self-assigned this
on Oct 9, 2023
mevdschee

mevdschee commented on Oct 9, 2023

@mevdschee
Owner

I've also have a repo available involving mysql, nginx, php-fpm and swagger to be up and running in seconds

Sounds great! Can you share a link with the community?

Is this a proposal to improve the docker-compose.yml?

nik2208

nik2208 commented on Oct 9, 2023

@nik2208
ContributorAuthor

talking abt swagger it can be considered an improvement, regarding the composition itself, it is actually an alternative, it uses nginx instead of apache and php-fpm (not exposed).
I have it in my gitlab, it includes cd-ci scripts with .env variables. how can we share/integrate it in here?

mevdschee

mevdschee commented on Oct 9, 2023

@mevdschee
Owner

how can we share/integrate it in here?

You could do a pr for an alternative (extended) docker-compose.yml, would that make sense?

Kind regards, Maurits

nik2208

nik2208 commented on Oct 9, 2023

@nik2208
ContributorAuthor

can it be bundled in a sub folder?

mevdschee

mevdschee commented on Oct 9, 2023

@mevdschee
Owner

I'm also fine with a separate project and I'll link to it from the README (that way you can receive credits/questions/suggestions), whatever you prefer.

nik2208

nik2208 commented on Oct 10, 2023

@nik2208
ContributorAuthor
nik2208

nik2208 commented on Oct 10, 2023

@nik2208
ContributorAuthor

I use envsubst to customise api.php configuration function.
So the api.php version is static and won't be updated.
a release-updated api.php.template file

$config = new Config([
        'driver' => 'mysql',
        'address' => 'mysql.php-api-network',
        'port' => '3306',
        'username' => '$MYSQL_USER',
        'password' => '$MYSQL_PASSWORD',
        'database' => '$MYSQL_DATABASE',
        'debug' => '$PHP_CRUD_API_DEBUG',
        'middlewares' => 'cors,json'
    ]);

would make it possible to download and publish the latest api.php version upon each deploy.
any other solution would be appreciated 😅

PS: I've added phpmyadmin image as well

mevdschee

mevdschee commented on Oct 11, 2023

@mevdschee
Owner

any other solution would be appreciated 😅

Can you use environment variables? They are supported, see: https://github.com/mevdschee/php-crud-api#configuration

mevdschee

mevdschee commented on Oct 11, 2023

@mevdschee
Owner

PS: I've added phpmyadmin image as well

I prefer adminer, see: https://www.adminer.org/

mevdschee

mevdschee commented on Oct 11, 2023

@mevdschee
Owner

I added a link to the readme, see: a0c5de0

nik2208

nik2208 commented on Oct 12, 2023

@nik2208
ContributorAuthor

Can you use environment variables? They are supported, see: https://github.com/mevdschee/php-crud-api#configuration

I didn't realise I could use them on docker as well

I prefer adminer, see: https://www.adminer.org/

ok I'll put it up

mevdschee

mevdschee commented on Oct 12, 2023

@mevdschee
Owner

ok I'll put it up

That's not what I meant.. I'm okay with PHPMyAdmin. Feel free to use either, I'm just sharing my (personal) preference. I wondered if you ever heard about it and you should try it.. it is great :-)

nik2208

nik2208 commented on Oct 12, 2023

@nik2208
ContributorAuthor

Yes of course no worries I completely trust u and ur opinions.. I'll give both the options.

Can you use environment variables? They are supported, see: https://github.com/mevdschee/php-crud-api#configuration

I've implemented it, if u ever have time, can u give it a spin? following the provided instructions it seems to simply work, just wondering if I'm doing something I give for grant that is not straightforward for others

nik2208

nik2208 commented on Oct 12, 2023

@nik2208
ContributorAuthor

ok two versions available, default featuring adminer, a branch named phpmyadmin featuring phpmyadmin

mevdschee

mevdschee commented on Oct 12, 2023

@mevdschee
Owner

I've implemented it, if u ever have time, can u give it a spin?

I did and I ran into an issue, see: nik2208/php-crud-api-quick-start#3

I also proposed a minor fix in the readme: nik2208/php-crud-api-quick-start#2

I hope you like that :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @mevdschee@nik2208

      Issue actions

        swagger docker-compose instant openapi · Issue #989 · mevdschee/php-crud-api