From a0daaee0960c7a1a7f4a256a47310f12f4fb2607 Mon Sep 17 00:00:00 2001 From: Ryn Cao Date: Tue, 9 Jul 2024 16:59:52 +0800 Subject: [PATCH] fix: add expose port --- .github/workflows/docker.yml | 15 ++++++++++----- Dockerfile | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fce4141..2c5581c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,7 +1,8 @@ name: Docker Try on: push: - branches: ["docker"] + branches: + - docker workflow_dispatch: workflow_call: @@ -16,11 +17,11 @@ jobs: image: cao7113/hello-api-elixir ports: - 4000:4000 - # Fix: unsupported media type application/vnd.oci.empty.v1+json - # use ghcr.io/cao7113/hello-api-elixir:v0.1.8 or ghcr.io/cao7113/hello-api-elixir:latest instead of ghcr.io/cao7113/hello-api-elixir:sha256-b3de0aa2c4d72189aeb6e36fe8377400e1f9e6f4fbc60270b3e05b2e3350462b + + # https://github.com/cao7113/hello-api-elixir/pkgs/container/hello-api-elixir + # Fix: "unsupported media type application/vnd.oci.empty.v1+json" + # use ghcr.io/cao7113/hello-api-elixir:v0.1.8 instead of ghcr.io/cao7113/hello-api-elixir:sha256-b3de0aa2c4d72189aeb6e36fe8377400e1f9e6f4fbc60270b3e05b2e3350462b api-server2: - # https://github.com/cao7113/hello-api-elixir/pkgs/container/hello-api-elixir - # image: ghcr.io/cao7113/hello-api-elixir:v0.1.8 image: ghcr.io/cao7113/hello-api-elixir ports: - 4002:4000 @@ -32,10 +33,14 @@ jobs: - name: Ping api-server run: | sleep 1 + echo Ping api-server curl -sSL http://localhost:4000/ping + echo Ping api-server2 curl -sSL http://localhost:4002/ping - name: Api build info run: | + echo api-server build info: curl -sSL http://localhost:4000 | jq + echo api-server2 build info: curl -sSL http://localhost:4002 | jq diff --git a/Dockerfile b/Dockerfile index 7805c60..00d8b38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,9 +83,11 @@ RUN chown nobody /app # set runner ENV ENV MIX_ENV="prod" +ENV PORT="4000" # Appended by flyctl https://fly.io/docs/elixir/getting-started/#important-ipv6-settings ENV ECTO_IPV6 true ENV ERL_AFLAGS "-proto_dist inet6_tcp" +EXPOSE ${PORT} # Only copy the final release from the build stage COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/hello_api ./