From 82f287372c827231c7dd7f57095ae60f15908f63 Mon Sep 17 00:00:00 2001 From: Cory Sanin Date: Thu, 3 Aug 2023 23:01:26 -0500 Subject: [PATCH] build(docker): build executable in docker --- .dockerignore | 35 +++++++++++++++++++++++++++++++---- Dockerfile | 24 +++++++++++++++++++++++- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index d1f98f1b..830774b6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,31 @@ -* -!docker/* -!docker_config.json -!filebrowser \ No newline at end of file +*.db +*.bak +_old +rice-box.go +.idea/ +/filebrowser +/filebrowser.exe +/dist + +.DS_Store +node_modules + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw* +bin/ +build/ diff --git a/Dockerfile b/Dockerfile index 40a91a06..4f0d9857 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,25 @@ +FROM node:alpine as frontend + +WORKDIR /filebrowser/frontend +COPY frontend/ . + +# TODO: Remove when frontend dependencies are updated +ENV NODE_OPTIONS --openssl-legacy-provider + +RUN npm install && \ + npx browserslist@latest --update-db &&\ + npm run build + + +FROM golang:alpine as backend + +WORKDIR /filebrowser +COPY . . +COPY --from=frontend /filebrowser /filebrowser +RUN go mod download && \ + go build + + FROM alpine:latest RUN apk --update add ca-certificates \ mailcap \ @@ -14,6 +36,6 @@ VOLUME /srv EXPOSE 80 COPY docker_config.json /.filebrowser.json -COPY filebrowser /filebrowser +COPY --from=backend /filebrowser/filebrowser /filebrowser ENTRYPOINT [ "/filebrowser" ] \ No newline at end of file