-
Notifications
You must be signed in to change notification settings - Fork 50
/
Dockerfile
116 lines (82 loc) · 2.45 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# syntax=docker/dockerfile:1
ARG UBUNTU_VERSION=22.04
FROM ubuntu:${UBUNTU_VERSION} as build
# Install dependencies
ENV DEBIAN_FRONTEND noninteractive
# hadolint ignore=DL3008
RUN <<EOT bash
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
libboost-dev \
libbz2-dev \
libpcap-dev \
ninja-build \
pkg-config \
python2.7 \
ragel \
wget \
zlib1g-dev
rm -rf /var/lib/apt/lists/*
EOT
# Download Hyperscan
ARG HYPERSCAN_VERSION=5.4.1
ENV HYPERSCAN_DIR=/hyperscan
WORKDIR ${HYPERSCAN_DIR}
ADD https://github.com/intel/hyperscan/archive/refs/tags/v${HYPERSCAN_VERSION}.tar.gz /hyperscan-v${HYPERSCAN_VERSION}.tar.gz
RUN <<EOT bash
tar xf /hyperscan-v${HYPERSCAN_VERSION}.tar.gz -C ${HYPERSCAN_DIR} --strip-components=1
rm /hyperscan-v${HYPERSCAN_VERSION}.tar.gz
EOT
ARG PCRE_VERSION=8.45
ADD https://sourceforge.net/projects/pcre/files/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.gz/download /pcre-${PCRE_VERSION}.tar.gz
WORKDIR ${HYPERSCAN_DIR}/pcre
RUN <<EOT bash
tar xf /pcre-${PCRE_VERSION}.tar.gz -C ${HYPERSCAN_DIR}/pcre --strip-components=1
rm /pcre-${PCRE_VERSION}.tar.gz
EOT
# Install Hyperscan
ENV INSTALL_DIR=/dist
WORKDIR ${HYPERSCAN_DIR}/build
ARG CMAKE_BUILD_TYPE=RelWithDebInfo
RUN <<EOT bash
cmake -G Ninja \
-DBUILD_STATIC_LIBS=ON \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
..
ninja
ninja install
mv ${HYPERSCAN_DIR}/build/lib/lib*.a ${INSTALL_DIR}/lib/
EOT
FROM ubuntu:${UBUNTU_VERSION}
# Install dependencies
ENV DEBIAN_FRONTEND noninteractive
# hadolint ignore=DL3008
RUN <<EOT bash
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
libpcap-dev \
pkg-config
rm -rf /var/lib/apt/lists/*
EOT
# Install golang
ARG GO_VERSION=1.20.3
ADD https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz /
RUN <<EOT bash
tar -C /usr/local -xzf /go${GO_VERSION}.linux-amd64.tar.gz
rm /go${GO_VERSION}.linux-amd64.tar.gz
EOT
ENV PATH="/usr/local/go/bin:${PATH}"
ENV INSTALL_DIR=/dist
COPY --from=build ${INSTALL_DIR} ${INSTALL_DIR}
ENV PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${INSTALL_DIR}/lib/pkgconfig"
# Add gohs code
COPY . /gohs/
WORKDIR /gohs
ENTRYPOINT ["/usr/local/go/bin/go"]
CMD ["test", "-v", "./..."]