Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change all imports and docker configuration #77

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading