2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-12-22 10:08:56 +00:00

#1402 Environment variables for custom image (#1403)

* chore: enhance compose.yaml with variables for customize

* chore: use default blank values for db and redis variables in compose.yaml

* chore: Use env var for HTTP(S) publish ports in overrides

* docs: explain use of environment variables for image customization

* chore: use ERPNEXT_VERSION as default

* docs: fixed spelling errors
This commit is contained in:
Yeifer Alexander Muñoz Torres 2024-06-07 13:51:17 -05:00 committed by GitHub
parent 9da4d22dd7
commit fa543662ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 38 additions and 17 deletions

View File

@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression, size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal level of experience, education, socioeconomic status, nationality, personal
appearance, race, religion, or sexual identity and orientation. appearance, race, religion, or sexual identity and orientation.
## Our Standards ## Our Standards

View File

@ -2,7 +2,8 @@ x-customizable-image: &customizable_image
# By default the image used only contains the `frappe` and `erpnext` apps. # By default the image used only contains the `frappe` and `erpnext` apps.
# See https://github.com/frappe/frappe_docker/blob/main/docs/custom-apps.md # See https://github.com/frappe/frappe_docker/blob/main/docs/custom-apps.md
# about using custom images. # about using custom images.
image: frappe/erpnext:${ERPNEXT_VERSION:?No ERPNext version set} image: ${CUSTOM_IMAGE:-frappe/erpnext}:${CUSTOM_TAG:-${ERPNEXT_VERSION:?No ERPNext version or tag set}}
pull_policy: ${PULL_POLICY:-always}
x-depends-on-configurator: &depends_on_configurator x-depends-on-configurator: &depends_on_configurator
depends_on: depends_on:
@ -32,10 +33,10 @@ services:
bench set-config -g redis_socketio "redis://$$REDIS_QUEUE"; bench set-config -g redis_socketio "redis://$$REDIS_QUEUE";
bench set-config -gp socketio_port $$SOCKETIO_PORT; bench set-config -gp socketio_port $$SOCKETIO_PORT;
environment: environment:
DB_HOST: ${DB_HOST} DB_HOST: ${DB_HOST:-}
DB_PORT: ${DB_PORT} DB_PORT: ${DB_PORT:-}
REDIS_CACHE: ${REDIS_CACHE} REDIS_CACHE: ${REDIS_CACHE:-}
REDIS_QUEUE: ${REDIS_QUEUE} REDIS_QUEUE: ${REDIS_QUEUE:-}
SOCKETIO_PORT: 9000 SOCKETIO_PORT: 9000
depends_on: {} depends_on: {}

View File

@ -104,14 +104,34 @@ More about [kaniko](https://github.com/GoogleContainerTools/kaniko)
### Use Images ### Use Images
On the [compose.yaml](../compose.yaml) replace the image reference to the `tag` you used when you built it. Then, if you used a tag like `custom_erpnext:staging` the `x-customizable-image` section will look like this: In the [compose.yaml](../compose.yaml), you can set the image name and tag through environment variables, making it easier to customize.
``` ```yaml
x-customizable-image: &customizable_image x-customizable-image: &customizable_image
image: custom_erpnext:staging image: ${CUSTOM_IMAGE:-frappe/erpnext}:${CUSTOM_TAG:-${ERPNEXT_VERSION:?No ERPNext version or tag set}}
pull_policy: never pull_policy: ${PULL_POLICY:-always}
``` ```
The `pull_policy` above is optional and prevents `docker` to try to download the image when that one has been built locally. The environment variables can be set in the shell or in the .env file as [setup-options.md](setup-options.md) describes.
- `CUSTOM_IMAGE`: The name of your custom image. Defaults to `frappe/erpnext` if not set.
- `CUSTOM_TAG`: The tag for your custom image. Must be set if `CUSTOM_IMAGE` is used. Defaults to the value of `ERPNEXT_VERSION` if not set.
- `PULL_POLICY`: The Docker pull policy. Defaults to `always`. Recommended set to `never` for local images, so prevent `docker` from trying to download the image when it has been built locally.
- `HTTP_PUBLISH_PORT`: The port to publish through no SSL channel. Default depending on deployment, it may be `80` if SSL activated or `8080` if not.
- `HTTPS_PUBLISH_PORT`: The secure port to publish using SSL. Default is `443`.
Make sure image name is correct to be pushed to registry. After the images are pushed, you can pull them to servers to be deployed. If the registry is private, additional auth is needed. Make sure image name is correct to be pushed to registry. After the images are pushed, you can pull them to servers to be deployed. If the registry is private, additional auth is needed.
#### Example
If you built an image with the tag `ghcr.io/user/repo/custom:1.0.0`, you would set the environment variables as follows:
```bash
export CUSTOM_IMAGE='ghcr.io/user/repo/custom'
export CUSTOM_TAG='1.0.0'
docker compose -f compose.yaml \
-f overrides/compose.mariadb.yaml \
-f overrides/compose.redis.yaml \
-f overrides/compose.https.yaml \
config > ~/gitops/docker-compose.yaml
```

View File

@ -21,8 +21,8 @@ services:
- --certificatesResolvers.main-resolver.acme.email=${LETSENCRYPT_EMAIL:?No Let's Encrypt email set} - --certificatesResolvers.main-resolver.acme.email=${LETSENCRYPT_EMAIL:?No Let's Encrypt email set}
- --certificatesResolvers.main-resolver.acme.storage=/letsencrypt/acme.json - --certificatesResolvers.main-resolver.acme.storage=/letsencrypt/acme.json
ports: ports:
- 80:80 - ${HTTP_PUBLISH_PORT:-80}:80
- 443:443 - ${HTTPS_PUBLISH_PORT:-443}:443
volumes: volumes:
- cert-data:/letsencrypt - cert-data:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro

View File

@ -1,4 +1,4 @@
services: services:
frontend: frontend:
ports: ports:
- 8080:8080 - ${HTTP_PUBLISH_PORT:-8080}:8080

View File

@ -13,7 +13,7 @@ services:
- --providers.docker.exposedbydefault=false - --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80 - --entrypoints.web.address=:80
ports: ports:
- 80:80 - ${HTTP_PUBLISH_PORT:-80}:80
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
userns_mode: host userns_mode: host

View File

@ -40,7 +40,7 @@ services:
# Enable the Dashboard and API # Enable the Dashboard and API
- --api - --api
ports: ports:
- 443:443 - ${HTTPS_PUBLISH_PORT:-443}:443
volumes: volumes:
- cert-data:/certificates - cert-data:/certificates

View File

@ -35,7 +35,7 @@ services:
# Enable the Dashboard and API # Enable the Dashboard and API
- --api - --api
ports: ports:
- 80:80 - ${HTTP_PUBLISH_PORT:-80}:80
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
networks: networks: