Skip to content

Commit 56333ed

Browse files
authored
feat!: add build different images for node, nginx, tools (#10)
1 parent d22e2fc commit 56333ed

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

.github/workflows/build_application_docker.yaml

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,69 @@ jobs:
4343
registry: ${{ env.REGISTRY }}
4444
username: ${{ github.actor }}
4545
password: ${{ secrets.GITHUB_TOKEN }}
46-
- name: Extract tags for Docker
47-
id: meta
46+
- name: Extract tags for Docker only Node.js
47+
id: meta-node
4848
uses: docker/[email protected]
4949
with:
5050
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5151
tags: |
5252
type=raw,value=latest
5353
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}
5454
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}.${{ env.BUILD_DATE }}
55-
- name: Build and push Docker image
55+
- name: Extract tags for Docker with Nginx and Node.js
56+
id: meta-nginx
57+
uses: docker/[email protected]
58+
with:
59+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60+
tags: |
61+
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-nginx
62+
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-nginx.${{ env.BUILD_DATE }}
63+
- name: Extract tags for Docker with additional packages
64+
id: meta-full
65+
uses: docker/[email protected]
66+
with:
67+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+
tags: |
69+
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-full
70+
type=raw,value=${{ env.IMAGE_UBUNTU_NODE_VERSION }}-full.${{ env.BUILD_DATE }}
71+
- name: Build and push Docker only Node.js
72+
uses: docker/[email protected]
73+
with:
74+
context: .
75+
push: true
76+
platforms: linux/amd64,linux/arm64
77+
tags: ${{ steps.meta-node.outputs.tags }}
78+
labels: ${{ steps.meta-node.outputs.labels }}
79+
cache-from: type=gha
80+
cache-to: type=gha,mode=max
81+
build-args: |
82+
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
83+
NODE_VERSION=${{ env.NODE_VERSION }}
84+
- name: Build and push Docker with Nginx and Node.js
85+
uses: docker/[email protected]
86+
with:
87+
context: .
88+
push: true
89+
platforms: linux/amd64,linux/arm64
90+
tags: ${{ steps.meta-nginx.outputs.tags }}
91+
labels: ${{ steps.meta-nginx.outputs.labels }}
92+
cache-from: type=gha
93+
cache-to: type=gha,mode=max
94+
build-args: |
95+
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
96+
NODE_VERSION=${{ env.NODE_VERSION }}
97+
ADDITIONAL_PACKAGES=nginx supervisor
98+
- name: Build and push Docker with additional packages
5699
uses: docker/[email protected]
57100
with:
58101
context: .
59102
push: true
60103
platforms: linux/amd64,linux/arm64
61-
tags: ${{ steps.meta.outputs.tags }}
62-
labels: ${{ steps.meta.outputs.labels }}
104+
tags: ${{ steps.meta-full.outputs.tags }}
105+
labels: ${{ steps.meta-full.outputs.labels }}
63106
cache-from: type=gha
64107
cache-to: type=gha,mode=max
65108
build-args: |
66109
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
67110
NODE_VERSION=${{ env.NODE_VERSION }}
111+
ADDITIONAL_PACKAGES=nginx supervisor nano vim curl git telnet bzip2 iproute2 wget

Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM ubuntu:${UBUNTU_VERSION}
44

55
# arg declarations
66
ARG NODE_MAJOR=20
7-
ARG CERT
7+
ARG ADDITIONAL_PACKAGES=""
88

99
ENV DEBIAN_FRONTEND=noninteractive
1010

@@ -15,7 +15,7 @@ RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
1515
# deps and nodejs installation
1616
RUN apt-get update && \
1717
apt-get -y upgrade && \
18-
apt-get -y install ca-certificates curl gnupg tzdata nano vim nginx curl git telnet bzip2 iproute2 wget supervisor && \
18+
apt-get -y install curl gnupg ${ADDITIONAL_PACKAGES} && \
1919
mkdir -p /etc/apt/keyrings && \
2020
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
2121
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 && \
2828
rm -rf /var/lib/apt/lists/* && \
2929
rm -rf /etc/nginx/sites-enabled/default
3030

31-
# adding certificate
32-
RUN echo $CERT > /usr/local/share/ca-certificates/cert.pem
33-
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/cert.pem
34-
RUN update-ca-certificates
35-
3631
# users setting
3732
RUN useradd -r app && mkdir /opt/app && chown app:app /opt/app

0 commit comments

Comments
 (0)