Skip to content

Commit 58f7a2e

Browse files
authored
Merge pull request #244 from Thunder-Blaze/feat/add-dockerignore
fix: Added .dockerignore and improved security
2 parents b80cda3 + 189874f commit 58f7a2e

3 files changed

Lines changed: 38 additions & 10 deletions

File tree

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.vscode/
2+
.cache/
3+
build/
4+
strfry
5+
*.md
6+
*.Dockerfile
7+
Dockerfile
8+
.gitignore
9+
10+

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ RUN \
4747
libressl \
4848
&& rm -rf /var/cache/apk/*
4949

50-
COPY --from=build /build/strfry strfry
51-
COPY --from=build /build/strfry.conf strfry.conf
52-
COPY --from=build /build/strfry-db strfry-db
50+
# Create a non-root user for security
51+
RUN adduser -D -h /app -s /bin/sh strfry && \
52+
chown -R strfry:strfry /app
53+
54+
# Switch to the unprivileged user
55+
USER strfry
56+
57+
COPY --from=build --chown=strfry:strfry /build/strfry /app/strfry
58+
COPY --from=build --chown=strfry:strfry /build/strfry.conf /app/strfry.conf
59+
COPY --from=build --chown=strfry:strfry /build/strfry-db /app/strfry-db
5360

5461
EXPOSE 7777
5562

ubuntu.Dockerfile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
# syntax=docker/dockerfile:1
12
FROM ubuntu:jammy AS build
23

34
ENV TZ=Europe/London
45

56
WORKDIR /build
67

7-
RUN apt update && apt install -y --no-install-recommends \
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
89
git g++ make pkg-config libtool ca-certificates \
910
libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev \
1011
libsecp256k1-dev libzstd-dev
1112

1213
COPY . .
1314

1415
RUN git submodule update --init
15-
1616
RUN make setup-golpe
1717

1818
RUN --mount=type=cache,target=/build/.cache \
@@ -22,13 +22,24 @@ FROM ubuntu:jammy AS runner
2222

2323
WORKDIR /app
2424

25-
RUN apt update && apt install -y --no-install-recommends \
26-
liblmdb0 libflatbuffers1 libsecp256k1-0 libb2-1 libzstd1 \
25+
RUN apt-get update && apt-get install -y --no-install-recommends \
26+
liblmdb0 \
27+
libsecp256k1-0 \
28+
libzstd1 \
29+
libflatbuffers1 \
30+
libb2-1 \
2731
&& rm -rf /var/lib/apt/lists/*
2832

29-
COPY --from=build /build/strfry strfry
30-
COPY --from=build /build/strfry.conf strfry.conf
31-
COPY --from=build /build/strfry-db strfry-db
33+
# Create a non-root user for security
34+
RUN useradd -m -d /app -s /bin/bash strfry && \
35+
chown -R strfry:strfry /app
36+
37+
# Switch to the unprivileged user
38+
USER strfry
39+
40+
COPY --from=build --chown=strfry:strfry /build/strfry /app/strfry
41+
COPY --from=build --chown=strfry:strfry /build/strfry.conf /app/strfry.conf
42+
COPY --from=build --chown=strfry:strfry /build/strfry-db /app/strfry-db
3243

3344
EXPOSE 7777
3445

0 commit comments

Comments
 (0)