forked from ajnart/homarr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 Improve dockerfile and start script and fix permission issue by add…
…ing new user with permission to read / write to /data folder
- Loading branch information
1 parent
351aa47
commit 2a1f733
Showing
6 changed files
with
48 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
FROM node:20.5-slim | ||
WORKDIR /app | ||
|
||
ARG UID=1001 | ||
ARG GID=1001 | ||
RUN groupadd -g $GID homarr-group | ||
RUN useradd -r -u $UID -g $GID homarr | ||
|
||
# Define node.js environment variables | ||
ARG PORT=7575 | ||
|
||
|
@@ -18,17 +23,30 @@ COPY .next/standalone ./ | |
COPY .next/static ./.next/static | ||
COPY ./scripts/run.sh ./scripts/run.sh | ||
COPY ./drizzle ./drizzle | ||
|
||
COPY ./drizzle/migrate ./migrate | ||
COPY ./tsconfig.json ./migrate/tsconfig.json | ||
|
||
RUN mkdir /data | ||
COPY ./src/migrate.ts ./src/migrate.ts | ||
RUN chown -R homarr:homarr-group /data | ||
|
||
# Install dependencies | ||
RUN apt-get update -y && apt-get install -y openssl wget | ||
|
||
# Required for migration | ||
# Move node_modules to temp location to avoid overwriting | ||
RUN mv node_modules _node_modules | ||
RUN rm package.json | ||
RUN yarn add typescript ts-node dotenv [email protected] [email protected] @types/better-sqlite3 | ||
RUN mv node_modules node_modules_migrate | ||
|
||
# Install dependencies for migration | ||
RUN cp ./migrate/package.json ./package.json | ||
RUN yarn | ||
|
||
# Copy better_sqlite3 build for current platform | ||
RUN cp /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/_node_modules/better-sqlite3/build/Release/better_sqlite3.node | ||
|
||
# Copy node_modules for migration to migrate folder for migration script | ||
RUN mv node_modules ./migrate/node_modules | ||
# Copy temp node_modules of app to app folder | ||
RUN mv _node_modules node_modules | ||
|
||
# Expose the default application port | ||
|
@@ -43,4 +61,8 @@ ENV NEXTAUTH_SECRET NOT_IN_USE_BECAUSE_JWTS_ARE_UNUSED | |
HEALTHCHECK --interval=10s --timeout=5s --start-period=5s --retries=3 \ | ||
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT} || exit 1 | ||
|
||
USER homarr | ||
|
||
CMD ["sh", "./scripts/run.sh"] | ||
|
||
# TEMPORARY: "db:migrate": "ts-node ./migrate.ts ../drizzle" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"scripts": { | ||
"db:migrate": "ts-node ./migrate.ts" | ||
}, | ||
"dependencies": { | ||
"@types/better-sqlite3": "^7.6.7", | ||
"better-sqlite3": "8.6.0", | ||
"drizzle-orm": "^0.28.6", | ||
"dotenv": "^16.3.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters