-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exoframe-website] Add recipe for using build args
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Using Docker Build Arguments | ||
|
||
Sometimes, you might need to pass dynamic variables to your project during build time. | ||
One way to achieve this is through [Docker build arguments](https://docs.docker.com/build/guide/build-args/). | ||
|
||
Exoframe supports passing build arguments via the project config. | ||
|
||
The example below demonstrates the use of build args with a custom Dockerfile to build a Next.js project. | ||
For a complete Dockerfile example, refer to the [Next.js docs](https://nextjs.org/docs/pages/building-your-application/deploying#docker-image). | ||
|
||
**Dockerfile:** | ||
|
||
```Dockerfile | ||
# ... copy values from args to env vars so that Next.js can use them | ||
ARG GRAPHQL_URL=http://default.endpoint.com/v1 | ||
ENV NEXT_PUBLIC_GRAPHQL_ENDPOINT=${GRAPHQL_URL} | ||
ARG SECRET_KEY | ||
ENV SECRET_KEY=${SECRET_KEY} | ||
|
||
# build app | ||
RUN npm run build | ||
|
||
# ... rest of Dockerfile | ||
``` | ||
|
||
**Exoframe Project Config:** | ||
|
||
```json | ||
{ | ||
"name": "example-buildargs-project", | ||
"buildargs": { | ||
"GRAPHQL_URL": "https://graphql.endpoint.com/v1", | ||
"SECRET_KEY": "@my-secret" | ||
} | ||
} | ||
``` |