ocean
ocean

Reputation: 27

How get teamcity env params in dockerfile?

I have several build steps in teamcity which build and push docker image. How can I get env params from teamcity in dockerfile. Now dockerfile looks like:

FROM python:3.8.9-slim-buster
ENV test24=2626
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8000
CMD [ "sh", "./app.sh" ]

Upvotes: 0

Views: 1566

Answers (1)

JohnXF
JohnXF

Reputation: 1097

You can pass --build-arg ARG_NAME=ARG_VALUE options to the docker build command, and within the Dockerfile you then have an ARG defined to pickup the value. eg:

ARG ARG_VALUE=DEFAULT_ARG_VALUE_IF_NOT_SPECIFIED

LABEL com.stackoverflow.arg="${ARG_VALUE}"

Upvotes: 1

Related Questions