diff --git a/.github/workflows/build_application_docker.yaml b/.github/workflows/build_application_docker.yaml index 5049cdb..af3fe90 100644 --- a/.github/workflows/build_application_docker.yaml +++ b/.github/workflows/build_application_docker.yaml @@ -43,8 +43,8 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract tags for Docker - id: meta + - name: Extract tags for Docker only Node.js + id: meta-node uses: docker/metadata-action@v5.0.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} @@ -52,16 +52,60 @@ jobs: type=raw,value=latest type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }} type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}.${{ env.BUILD_DATE }} - - name: Build and push Docker image + - name: Extract tags for Docker with Nginx and Node.js + id: meta-nginx + uses: docker/metadata-action@v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-nginx + type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-nginx.${{ env.BUILD_DATE }} + - name: Extract tags for Docker with additional packages + id: meta-full + uses: docker/metadata-action@v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-full + type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-full.${{ env.BUILD_DATE }} + - name: Build and push Docker only Node.js + uses: docker/build-push-action@v6.0.0 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta-node.outputs.tags }} + labels: ${{ steps.meta-node.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + UBUNTU_VERSION=${{ env.UBUNTU_VERSION }} + NODE_VERSION=${{ env.NODE_VERSION }} + - name: Build and push Docker with Nginx and Node.js + uses: docker/build-push-action@v6.0.0 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta-nginx.outputs.tags }} + labels: ${{ steps.meta-nginx.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + UBUNTU_VERSION=${{ env.UBUNTU_VERSION }} + NODE_VERSION=${{ env.NODE_VERSION }} + ADDITIONAL_PACKAGES=nginx supervisor + - name: Build and push Docker with additional packages uses: docker/build-push-action@v6.0.0 with: context: . push: true platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta-full.outputs.tags }} + labels: ${{ steps.meta-full.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max build-args: | UBUNTU_VERSION=${{ env.UBUNTU_VERSION }} NODE_VERSION=${{ env.NODE_VERSION }} + ADDITIONAL_PACKAGES=nginx supervisor nano vim curl git telnet bzip2 iproute2 wget diff --git a/Dockerfile b/Dockerfile index ff8d744..72d138c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:${UBUNTU_VERSION} # arg declarations ARG NODE_MAJOR=20 -ARG CERT +ARG ADDITIONAL_PACKAGES="" ENV DEBIAN_FRONTEND=noninteractive @@ -15,7 +15,7 @@ RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # deps and nodejs installation RUN apt-get update && \ apt-get -y upgrade && \ - apt-get -y install ca-certificates curl gnupg tzdata nano vim nginx curl git telnet bzip2 iproute2 wget supervisor && \ + apt-get -y install curl gnupg ${ADDITIONAL_PACKAGES} && \ mkdir -p /etc/apt/keyrings && \ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ @@ -28,10 +28,5 @@ RUN apt-get -y purge curl gnupg gnupg2 && \ rm -rf /var/lib/apt/lists/* && \ rm -rf /etc/nginx/sites-enabled/default -# adding certificate -RUN echo $CERT > /usr/local/share/ca-certificates/cert.pem -ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/cert.pem -RUN update-ca-certificates - # users setting RUN useradd -r app && mkdir /opt/app && chown app:app /opt/app