From 8cc0d3036cea2080a12e11c981f0ba8b54a55bdf Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Fri, 8 Jul 2022 17:57:15 +0300 Subject: [PATCH] TD-222: Sync Dockerfiles w/ valitydev/erlang-templates (#25) * Switch to valitydev/action-deploy-docker@v2 --- .github/workflows/build-image.yml | 2 +- Dockerfile | 19 +++++++++---------- Dockerfile.dev | 9 ++++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 5e21051..ff53b0e 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -15,7 +15,7 @@ jobs: build-push: runs-on: ubuntu-latest steps: - - uses: valitydev/action-deploy-docker@634e37d1a5367a0d3029a271b1112f22ce891d23 + - uses: valitydev/action-deploy-docker@v2 with: registry-username: ${{ github.actor }} registry-access-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 6fc6039..ec0732d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,12 @@ ARG OTP_VERSION # Build the release FROM docker.io/library/erlang:${OTP_VERSION} AS builder - -ARG BUILDARCH +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Install thrift compiler ARG THRIFT_VERSION - -RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${BUILDARCH}.tar.gz" \ +ARG TARGETARCH +RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${TARGETARCH}.tar.gz" \ | tar -xvz -C /usr/local/bin/ # Copy sources @@ -17,8 +16,8 @@ COPY . /build/ # Build the release WORKDIR /build -RUN rebar3 compile -RUN rebar3 as prod release +RUN rebar3 compile && \ + rebar3 as prod release # Make a runner image FROM docker.io/library/erlang:${OTP_VERSION}-slim @@ -29,15 +28,15 @@ ARG SERVICE_NAME ENV CHARSET=UTF-8 ENV LANG=C.UTF-8 -# Expose SERVICE_NAME as env so CMD expands properly on start -ENV SERVICE_NAME=${SERVICE_NAME} - # Set runtime WORKDIR /opt/${SERVICE_NAME} COPY --from=builder /build/_build/prod/rel/${SERVICE_NAME} /opt/${SERVICE_NAME} +RUN echo "#!/bin/sh" >> /entrypoint.sh && \ + echo "exec /opt/${SERVICE_NAME}/bin/${SERVICE_NAME} foreground" >> /entrypoint.sh && \ + chmod +x /entrypoint.sh ENTRYPOINT [] -CMD /opt/${SERVICE_NAME}/bin/${SERVICE_NAME} foreground +CMD ["/entrypoint.sh"] EXPOSE 8022 diff --git a/Dockerfile.dev b/Dockerfile.dev index 54f1170..e4cfa53 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,13 +1,12 @@ ARG OTP_VERSION FROM docker.io/library/erlang:${OTP_VERSION} - -ARG BUILDARCH +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Install thrift compiler ARG THRIFT_VERSION - -RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${BUILDARCH}.tar.gz" \ +ARG TARGETARCH +RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${TARGETARCH}.tar.gz" \ | tar -xvz -C /usr/local/bin/ # Set env @@ -15,4 +14,4 @@ ENV CHARSET=UTF-8 ENV LANG=C.UTF-8 # Set runtime -CMD /bin/bash +CMD ["/bin/bash"]