File tree 6 files changed +42
-4
lines changed
6 files changed +42
-4
lines changed Original file line number Diff line number Diff line change
1
+ FROM alpine:3.20.2 AS builder
2
+
3
+ RUN apk update && apk add --no-cache g++ make cmake
4
+
5
+ WORKDIR /app
6
+
7
+ COPY example /app/example
8
+ COPY include /app/include
9
+ COPY lib /app/lib
10
+ COPY src /app/src
11
+ COPY CMakeLists.txt /app/CMakeLists.txt
12
+
13
+ RUN mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_EXE_LINKER_FLAGS="-static" .. && make
14
+ RUN chmod +x /app/build/brewtils
15
+
16
+ FROM scratch
17
+
18
+ WORKDIR /app
19
+
20
+ COPY --from=builder /app/build/brewtils /app/brewtils
21
+
22
+ ENTRYPOINT ["/app/brewtils" ]
Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ int main(int argc, char **argv) {
56
56
logger::info (file);
57
57
}
58
58
59
+ logger::info (" ---------------------------" );
60
+ logger::info (brewtils::os::isDocker () ? " Running in Docker"
61
+ : " Not in Docker" );
62
+
59
63
logger::info (" ---------------------------" );
60
64
logger::info (brewtils::os::file::getMimeType (" test.txt" ));
61
65
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ std::string joinPath(const std::string &path1,
12
12
13
13
std::string basePath (const std::string &path) noexcept (true );
14
14
15
+ bool isDocker () noexcept (true );
16
+
15
17
} // namespace os
16
18
17
19
} // namespace brewtils
Original file line number Diff line number Diff line change 3
3
#include < filesystem>
4
4
#include < fstream>
5
5
#include < map>
6
- #include < set>
7
- #include < string>
8
6
9
7
#include < logger/log.h>
10
8
Original file line number Diff line number Diff line change @@ -18,3 +18,7 @@ std::string brewtils::os::basePath(const std::string &path) noexcept(true) {
18
18
size_t pos = base.find_last_of (' /' );
19
19
return base.substr (pos + 1 , base.size ());
20
20
}
21
+
22
+ bool brewtils::os::isDocker () noexcept (true ) {
23
+ return brewtils::os::file::exists (" /.dockerenv" );
24
+ }
Original file line number Diff line number Diff line change @@ -57,8 +57,16 @@ brewtils::os::dir::tree(const std::string &path) noexcept(false) {
57
57
std::set<std::string> files;
58
58
for (const std::filesystem::directory_entry &entry :
59
59
std::filesystem::recursive_directory_iterator (path)) {
60
- relativePath = std::filesystem::relative (entry.path (), path).string ();
61
- files.insert (relativePath);
60
+ try {
61
+ if (!entry.is_regular_file () && !entry.is_directory ()) {
62
+ continue ;
63
+ }
64
+
65
+ relativePath = std::filesystem::relative (entry.path (), path).string ();
66
+ files.insert (relativePath);
67
+ } catch (const std::filesystem::filesystem_error &e) {
68
+ continue ;
69
+ }
62
70
}
63
71
64
72
return files;
You can’t perform that action at this time.
0 commit comments