Skip to content

Commit

Permalink
Merge pull request #77 from jd-apprentice/refactor/imports-and-docker
Browse files Browse the repository at this point in the history
refactor: change all imports and docker configuration
  • Loading branch information
jd-apprentice authored Sep 13, 2024
2 parents c2eb916 + 9a1f9e7 commit 15c0fc9
Show file tree
Hide file tree
Showing 6 changed files with 881 additions and 17 deletions.
13 changes: 0 additions & 13 deletions docker-compose.yml

This file was deleted.

8 changes: 7 additions & 1 deletion Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM oven/bun:1 AS base
WORKDIR /usr/src/app

FROM base AS install

RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile
Expand All @@ -15,12 +16,17 @@ COPY --from=install /temp/dev/node_modules node_modules
COPY . .

ENV NODE_ENV=production
RUN bun run lint
RUN bun run build

FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/dist ./dist

RUN mkdir -p /usr/src/app/src/image/assets/images
RUN chown -R bun:bun /usr/src/app/src/image/assets/images
RUN chmod -R 600 /usr/src/app/src/image/assets/images

USER bun
EXPOSE 4000/tcp
ENTRYPOINT [ "bun", "run", "dist/app/index.js" ]
ENTRYPOINT [ "bun", "dist/index.js" ]
25 changes: 25 additions & 0 deletions docker/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
waifuland:
container_name: waifuland
## https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
security_opt:
- seccomp:seccomp.json
- apparmor:non-root-profile
- no-new-privileges:true
build:
context: ../
dockerfile: docker/Dockerfile
## https://dockerlabs.collabnix.com/advanced/security/capabilities/
cap_add: ["DAC_OVERRIDE"]
cap_drop: ["ALL"]
restart: always
env_file:
- ../.env
ports:
- 4000:4000
networks:
- waifuland

networks:
waifuland:
driver: bridge
12 changes: 12 additions & 0 deletions docker/non-root-profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include <tunables/global>
include <abstractions/base>

/usr/src/app {
deny capability sys_admin,
/usr/src/app/** ix,
}

/dist {
deny capability sys_admin,
/dist/** ix,
}
Loading

0 comments on commit 15c0fc9

Please sign in to comment.