From bb4b694c474c5e5fb2542ce659859433067f5639 Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:05:56 -0400 Subject: [PATCH 1/3] smtp/pop: Containerfile: Remove old dead code These commented out lines are a relic from when the base image was fedora, and were only useful for debugging. They never should have even been commited. --- pop/Containerfile | 2 -- smtp/Containerfile | 2 -- 2 files changed, 4 deletions(-) diff --git a/pop/Containerfile b/pop/Containerfile index 4ca055cc..316fc644 100644 --- a/pop/Containerfile +++ b/pop/Containerfile @@ -10,8 +10,6 @@ RUN make -C /pop CC='clang -static' RUN mkdir -p /mnt/mail -#FROM fedora:latest as smtp -#RUN dnf -y update && dnf -y install libselinux-utils && dnf clean all FROM scratch as pop COPY --from=build /mnt/mail /mnt/mail VOLUME /mnt/mail diff --git a/smtp/Containerfile b/smtp/Containerfile index c29ca021..6c4ed56d 100644 --- a/smtp/Containerfile +++ b/smtp/Containerfile @@ -13,8 +13,6 @@ RUN make -C /smtp CC='clang -static' SRVNAME=$hostname RUN mkdir -p /mnt/email_data/mail /mnt/email_data/logs -#FROM fedora:latest as smtp -#RUN dnf -y update && dnf -y install libselinux-utils && dnf clean all FROM scratch as smtp COPY --from=build /mnt/email_data /mnt/email_data VOLUME /mnt/email_data/ From a2ffad480f993cee83a5bba3294175e633bfca4e Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:09:47 -0400 Subject: [PATCH 2/3] tcp_server/smtp/pop: Containerfile: prefer COPY to ADD int this case, there is no function difference, but that is exactly why it is preferable, because when you are not using the additional features of the ADD instruction, why not make your intent clearer to the reader by using the unambigious and simpler COPY instruction. --- pop/Containerfile | 2 +- smtp/Containerfile | 2 +- tcp_server/Containerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pop/Containerfile b/pop/Containerfile index 316fc644..59f78803 100644 --- a/pop/Containerfile +++ b/pop/Containerfile @@ -4,7 +4,7 @@ RUN apk add \ make \ ; -ADD . /pop +COPY . /pop RUN make -C /pop CC='clang -static' diff --git a/smtp/Containerfile b/smtp/Containerfile index 6c4ed56d..ab6e5d29 100644 --- a/smtp/Containerfile +++ b/smtp/Containerfile @@ -4,7 +4,7 @@ RUN apk add \ make \ ; -ADD . /smtp +COPY . /smtp ARG hostname RUN test -n "$hostname" || (echo 'hostname is not set' && false) diff --git a/tcp_server/Containerfile b/tcp_server/Containerfile index 49651d3d..73f7808c 100644 --- a/tcp_server/Containerfile +++ b/tcp_server/Containerfile @@ -4,7 +4,7 @@ RUN apk add \ make \ ; -ADD . /tcp_server +COPY . /tcp_server RUN make -C /tcp_server CC='clang -static' From a81047ae7439b1e78b3f9a1e16c668faf83132ba Mon Sep 17 00:00:00 2001 From: charliemirabile <46761267+charliemirabile@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:09:58 -0400 Subject: [PATCH 3/3] tcp_server/smtp/pop: Makefile: add debug toggle with make argument Instead of needing to edit the makefile to uncomment the line that adds debugging options to the CFLAGS, just check if a make variable is defined so that consumers can specify `make DEBUG=true` to perform a debug build --- pop/Makefile | 5 ++++- smtp/Makefile | 6 +++++- tcp_server/Makefile | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pop/Makefile b/pop/Makefile index 6fb17615..cf56f305 100644 --- a/pop/Makefile +++ b/pop/Makefile @@ -1,7 +1,10 @@ CC = clang CFLAGS = -std=c2x -Weverything -Wno-unsafe-buffer-usage -Wno-c++98-compat -Wno-gnu-designator -Wno-gnu-case-range -Wno-initializer-overrides \ -Wno-declaration-after-statement -Wno-four-char-constants -Wno-pre-c2x-compat -Wno-disabled-macro-expansion -D_GNU_SOURCE -#CFLAGS += -DDEBUG -Og -g + +ifdef DEBUG + CFLAGS += -DDEBUG -Og -g +endif .PHONY: all clean diff --git a/smtp/Makefile b/smtp/Makefile index c9fa2b2a..8ea9e43e 100644 --- a/smtp/Makefile +++ b/smtp/Makefile @@ -2,7 +2,11 @@ CC = clang CFLAGS = -std=c2x -Weverything -Wno-unsafe-buffer-usage -Wno-c++98-compat -Wno-gnu-designator \ -Wno-initializer-overrides -Wno-declaration-after-statement -Wno-four-char-constants \ -Wno-pre-c2x-compat -Wno-disabled-macro-expansion -D_GNU_SOURCE -DHOSTNAME='"$(SRVNAME)"' -#CFLAGS += -DDEBUG -Og -g + +ifdef DEBUG + CFLAGS += -DDEBUG -Og -g +endif + .PHONY: all clean all: smtp diff --git a/tcp_server/Makefile b/tcp_server/Makefile index 6b6ec35e..517bd755 100644 --- a/tcp_server/Makefile +++ b/tcp_server/Makefile @@ -1,7 +1,10 @@ CC = clang CFLAGS = -std=c2x -Weverything -Wno-declaration-after-statement -Wno-c++98-compat -Wno-padded \ -Wno-unsafe-buffer-usage -Wno-disabled-macro-expansion -Wno-pre-c2x-compat -D_GNU_SOURCE -#CFLAGS += -DDEBUG -Og -g + +ifdef DEBUG + CFLAGS += -DDEBUG -Og -g +endif .PHONY: all clean