i have this docker file
FROM node:14-slim AS ui-build
WORKDIR /usr/src
COPY ui/ ./ui/
RUN cd ui && npm install && npm run build
FROM node:14-slim AS api-build
WORKDIR /usr/src
COPY api/ ./api/
ENV ENVIRONMENT test
ENV URI test
RUN cd api && npm install && npm run build
RUN ls
FROM node:14-slim
WORKDIR /root/
COPY --from=ui-build /usr/src/ui/build ./ui/build
COPY --from=api-build /usr/src/api/dist .
RUN ls
EXPOSE 80
CMD ["node", "api.bundle.js"]
and this task definition in terraform
resource "aws_ecs_task_definition" "main" {
family = var.task_name
network_mode = var.net_mode
requires_compatibilities = [var.ecs_type]
cpu = var.container_cpu
memory = var.container_memory
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
container_definitions = jsonencode([{
name = var.container_name
image = var.container_image
essential = var.essential
environment = [{"name": "ENVIRONMENT", "value": "${var.environment}"}, {"name": "URI", "value": "${var.uridb}"}] //this envs will be pass to the container to select deploy enviroment
portMappings = [{
protocol = var.protocol
containerPort = tonumber(var.container_port)
hostPort = tonumber(var.container_host_port)
}]
logConfiguration = {
logDriver = var.log_driver
options = {
awslogs-group = aws_cloudwatch_log_group.main_lgr.name
awslogs-stream-prefix = "ecs"
//awslogs-create-group = "true" // creates new log group with awslogs-grou
awslogs-region = var.region
}
}
}])
tags = {
Environment = var.environment
}
depends_on = [aws_iam_role.ecs_task_execution_role]
}
taking a look inside my container it would seen that the envs in my docker file have presedence over the ones in the task definition
how can i make my task definition ENVS have priority over the ones in the container once i run my service?