prepare for dockerizing
This commit is contained in:
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
FROM alpine:3.13 AS builder
|
||||||
|
|
||||||
|
ARG VERSION
|
||||||
|
|
||||||
|
COPY sink/ /tmp/sink
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apk update && \
|
||||||
|
apk add alpine-sdk && \
|
||||||
|
apk add libconfig-dev && \
|
||||||
|
apk add postgresql-dev && \
|
||||||
|
cd /tmp/sink && \
|
||||||
|
make VERSION=${VERSION}
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:3.13
|
||||||
|
|
||||||
|
COPY --from=builder /tmp/sink/build/sink20169 /usr/local/bin/
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apk add --no-cache libpq && \
|
||||||
|
apk add --no-cache libconfig && \
|
||||||
|
mkdir /etc/sink
|
||||||
|
|
||||||
|
EXPOSE 20169/udp
|
||||||
|
|
||||||
|
VOLUME /etc/sink
|
||||||
|
|
||||||
|
CMD [ "/usr/local/bin/sink20169", "-f", "/etc/sink/sink20169.cfg", "-n", "nobody", "-v" ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@ sha256.c \
|
|||||||
sink20169.c \
|
sink20169.c \
|
||||||
logging.c
|
logging.c
|
||||||
|
|
||||||
VERSION := $(shell git rev-parse --short=8 HEAD)
|
VERSION ?= $(shell git rev-parse --short=8 HEAD)
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern bool verbose;
|
extern bool verbose;
|
||||||
|
extern bool debug;
|
||||||
|
|
||||||
int facility = LOG_LOCAL0;
|
int facility = LOG_LOCAL0;
|
||||||
|
|
||||||
void setfacility(const char *facility_p) {
|
void setfacility(const char *facility_p) {
|
||||||
@ -42,7 +44,7 @@ void logmsg(int prio, const char* format, ...) {
|
|||||||
vsnprintf(buf, sizeof(buf), format, vl);
|
vsnprintf(buf, sizeof(buf), format, vl);
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose && (debug || (prio != LOG_DEBUG))) {
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ typedef struct {
|
|||||||
} t_commonHandle;
|
} t_commonHandle;
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
bool debug = false;
|
||||||
|
|
||||||
|
|
||||||
int openDatabaseConnection(t_commonHandle *handle) {
|
int openDatabaseConnection(t_commonHandle *handle) {
|
||||||
@ -347,6 +347,7 @@ void usage() {
|
|||||||
printf("\nUsage\n");
|
printf("\nUsage\n");
|
||||||
printf(" -f FILENAME ...... Config file to be used\n");
|
printf(" -f FILENAME ...... Config file to be used\n");
|
||||||
printf(" -v ............... Verbose, writes all logging on stdout too\n");
|
printf(" -v ............... Verbose, writes all logging on stdout too\n");
|
||||||
|
printf(" -d ............... Also log debug output\n");
|
||||||
printf(" -s FACILITY ...... Sets syslog facility, only LOCAL[0..7]\n");
|
printf(" -s FACILITY ...... Sets syslog facility, only LOCAL[0..7]\n");
|
||||||
printf(" USER and DAEMON are supported\n");
|
printf(" USER and DAEMON are supported\n");
|
||||||
printf(" -n USER .......... If started as root drop privileges and become\n");
|
printf(" -n USER .......... If started as root drop privileges and become\n");
|
||||||
@ -374,6 +375,9 @@ int main(int argc, char **argv) {
|
|||||||
case 'v':
|
case 'v':
|
||||||
verbose = true;
|
verbose = true;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
debug = true;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
setfacility(optarg);
|
setfacility(optarg);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user