ASPNETCORE_URLS ARG не используется при запуске docker-compose - PullRequest
1 голос
/ 01 мая 2019

У меня есть ASP.NET Core API с Postgres Db.Я пытаюсь Dockerize всего приложения.

Вот мой Dockerfile:

# set base image as the dotnet 2.2 SDK.
FROM microsoft/dotnet:2.2-sdk AS build-env

# set the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD
# instructions that follows the WORKDIR instruction.
WORKDIR /app

# our current working directory within the container is /app
# we now copy all the files (from local machine) to /app (in the container).
COPY . ./

# again, on the container (we are in /app folder)
# we now publish the project into a folder called 'out'.
RUN dotnet publish Bejebeje.Api/Bejebeje.Api.csproj -c Release -o out

# set base image as the dotnet 2.2 runtime.
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS runtime

# local variable
ARG customport

# temporary test to make sure the variable is coming through.
RUN echo "ASPNETCORE_URLS -> $customport"

# telling the application what port to run on.
ENV ASPNETCORE_URLS=$customport

# set the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD
# instructions that follows the WORKDIR instruction.
WORKDIR /app

# copy the contents of /app/out in the `build-env` and paste it in the
# `/app` directory of the new runtime container.
COPY --from=build-env /app/Bejebeje.Api/out .

# set the entry point into the application.
ENTRYPOINT ["dotnet", "Bejebeje.Api.dll", "-seed"]

А вот мой docker-compose.yml:

version: "3.7"

services:
  bejebeje-api:
    build:
      context: .
      dockerfile: ./Bejebeje.Api/Dockerfile
      args:
        - customport=http://*5005
      labels:
        com.bejebeje.description: "Bejebeje's API"
    image: bejebeje-api:latest
    ports:
      - "5005:5005"
    env_file:
      - ./variables.env
    depends_on:
      - database
  database:
    image: postgres
    ports:
      - "8002:5432"
    volumes:
      - data-volume:/var/lib/postgresql/data
    env_file:
      - ./variables.env

volumes:
  data-volume:

Я первыйзапустите docker-compose build, и я смогу увидеть

Step 7/12 : RUN echo "ASPNETCORE_URLS -> $customport"
 ---> Running in cd127d488021
ASPNETCORE_URLS -> http://*5005

Так что мой пользовательский аргумент проходит, но когда я запускаю docker-compose up, приложение по-прежнему работает на порту 80, а не 5005.

Мой variables.env имеет следующее:

FrontendCorsOrigin=http://localhost:1234
ApiName=bejebeje-api
Authority=http://localhost:5000
Database__DefaultConnectionString=Server=database;Port=5432;Database=DbName;User Id=postgres;Password=awesomePass;
POSTGRES_PASSWORD=awesomePass
POSTGRES_DB=DbName

cmd

Что я делаю не так?

...