Skip to content

Commit

Permalink
Merge pull request #101 from linkorb/bring-your-own-docker-9101
Browse files Browse the repository at this point in the history
Flag to make devcontainer configuration use root level docker-compose.yaml file #9101
  • Loading branch information
mhitza authored Nov 15, 2024
2 parents 723c938 + ebb2c44 commit 3cf9ffa
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ your repository.
| github<br>features<br>wiki `boolean` |false| Enable Wiki tab.|
| github<br>features<br>issues `boolean` |false| Enable issues tab.|
| github<br>features<br>projects `boolean` |false| Enable projects tab.|
| helm_charts `boolean` |false| Enable generation of Helm charts.|
| devcontainer<br>custom_docker_compose_yaml `boolean` |false| When enabled no pre-defined .devcontainer/docker-compose.yaml file will be generated, and instead the devcontainer will attempt to use a docker-compose.yaml file located in the root of the repository.|
| devcontainer<br>postCreateCommand `string` |-| Additional (shell) commands to run when the containers is created. For a typical project you would specify commands that only need to run once when the project is setup. For example you might add a command in here to load database fixtures for your project.|
| devcontainer<br>postStartCommand `string` |-| Additional (shell) commands to run when the container is started. This event takes place after the create event, but opposed to the create event it's triggered every time the container is started (including when it's resumed from a suspended state). In a typical JavaScript application you might set it to run a `npm run dev` or equivalent step.|
| devcontainer<br>customizations_vscode<br>extensions `array` |-| Additional extensions to install. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file for extensions installed by default.|
| devcontainer<br>customizations_vscode<br>settings `object` |-| Settings overrides for VSCode and installed extensions. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file regarding proper format and default values.|
| devcontainer<br>private_packagist `boolean` |true| Repository requires private packagist access. Property is ignored is not of type php-*, or the other (deprecated) types: application, library, symfony-bundle.|
| devcontainer<br>repository `string` |ghcr.io/linkorb/php-docker-base| Image to use for devcontainer (registry image URL)|
| devcontainer<br>tag `string` |php8-review| Image tag|
| helm_charts `boolean` |false| Enable generation of Helm charts.|
| archived `boolean` |false| Setting this option to `true` will cause the repository to be archived. Once archived, it can only be unarchived manually.|
- [Looking for repo.yaml schema integration within your IDE?](./docs/SchemaIDESupport.md)

Expand Down
3 changes: 2 additions & 1 deletion docs/partials/readme.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
| github<br>features<br>wiki `boolean` |false| Enable Wiki tab.|
| github<br>features<br>issues `boolean` |false| Enable issues tab.|
| github<br>features<br>projects `boolean` |false| Enable projects tab.|
| helm_charts `boolean` |false| Enable generation of Helm charts.|
| devcontainer<br>custom_docker_compose_yaml `boolean` |false| When enabled no pre-defined .devcontainer/docker-compose.yaml file will be generated, and instead the devcontainer will attempt to use a docker-compose.yaml file located in the root of the repository.|
| devcontainer<br>postCreateCommand `string` |-| Additional (shell) commands to run when the containers is created. For a typical project you would specify commands that only need to run once when the project is setup. For example you might add a command in here to load database fixtures for your project.|
| devcontainer<br>postStartCommand `string` |-| Additional (shell) commands to run when the container is started. This event takes place after the create event, but opposed to the create event it's triggered every time the container is started (including when it's resumed from a suspended state). In a typical JavaScript application you might set it to run a `npm run dev` or equivalent step.|
| devcontainer<br>customizations_vscode<br>extensions `array` |-| Additional extensions to install. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file for extensions installed by default.|
| devcontainer<br>customizations_vscode<br>settings `object` |-| Settings overrides for VSCode and installed extensions. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file regarding proper format and default values.|
| devcontainer<br>private_packagist `boolean` |true| Repository requires private packagist access. Property is ignored is not of type php-*, or the other (deprecated) types: application, library, symfony-bundle.|
| devcontainer<br>repository `string` |ghcr.io/linkorb/php-docker-base| Image to use for devcontainer (registry image URL)|
| devcontainer<br>tag `string` |php8-review| Image tag|
| helm_charts `boolean` |false| Enable generation of Helm charts.|
| archived `boolean` |false| Setting this option to `true` will cause the repository to be archived. Once archived, it can only be unarchived manually.|
16 changes: 11 additions & 5 deletions repo.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ properties:
type: boolean
default: false

helm_charts:
type: boolean
default: false
description: Enable generation of Helm charts.

php:
type: object
description: PHP specific values
Expand All @@ -207,6 +202,12 @@ properties:
type: object
description: Devcontainer specific values
properties:
custom_docker_compose_yaml:
type: boolean
default: false
description: >
When enabled no pre-defined .devcontainer/docker-compose.yaml file will be generated, and instead the
devcontainer will attempt to use a docker-compose.yaml file located in the root of the repository.
postCreateCommand:
description: >
Additional (shell) commands to run when the containers is created. For a typical project you would specify
Expand Down Expand Up @@ -256,6 +257,11 @@ properties:
type: string
default: php8-review

helm_charts:
type: boolean
default: false
description: Enable generation of Helm charts.

phpqa:
type: object
description: phpqa tools specific values
Expand Down
19 changes: 11 additions & 8 deletions tasks/devcontainer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
state: directory
when: not devcontainer_folder.stat.exists

- name: generate .devcontainer/docker-compose.yml
ansible.builtin.template:
src: "{{ './templates/.devcontainer/docker-compose.yml.j2' }}"
dest: "{{ repo_path + '/.devcontainer/docker-compose.yml' }}"
- name: pre-defined docker-compose.yml & Dockerfile
when: not repo.devcontainer.custom_docker_compose_yaml
block:
- name: generate .devcontainer/docker-compose.yml
ansible.builtin.template:
src: "{{ './templates/.devcontainer/docker-compose.yml.j2' }}"
dest: "{{ repo_path + '/.devcontainer/docker-compose.yml' }}"

- name: generate .devcontainer/Dockerfile
ansible.builtin.template:
src: "{{ './templates/.devcontainer/Dockerfile.j2' }}"
dest: "{{ repo_path + '/.devcontainer/Dockerfile' }}"
- name: generate .devcontainer/Dockerfile
ansible.builtin.template:
src: "{{ './templates/.devcontainer/Dockerfile.j2' }}"
dest: "{{ repo_path + '/.devcontainer/Dockerfile' }}"

- name: generate .devcontainer/devcontainer.json
ansible.builtin.template:
Expand Down
4 changes: 4 additions & 0 deletions templates/.devcontainer/devcontainer.json.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// {{ repo_managed }}
{
{% if repo.devcontainer.custom_docker_compose_yaml %}
"dockerComposeFile": "../docker-compose.yaml",
{% else %}
"dockerComposeFile": "docker-compose.yml",
{% endif %}
"service": "app",
"workspaceFolder": "/app",

Expand Down

0 comments on commit 3cf9ffa

Please sign in to comment.