docker guest build, docker-compose
This commit is contained in:
parent
7892fbcb58
commit
04991df5ef
@ -3,6 +3,6 @@
|
|||||||
"baseURL": "",
|
"baseURL": "",
|
||||||
"address": "",
|
"address": "",
|
||||||
"log": "stdout",
|
"log": "stdout",
|
||||||
"database": "/database.db",
|
"database": "/database/database.db",
|
||||||
"root": "/srv"
|
"root": "/srv"
|
||||||
}
|
}
|
||||||
|
|||||||
60
Dockerfile
60
Dockerfile
@ -1,65 +1,13 @@
|
|||||||
# Build the frontend
|
FROM alpine:latest as certs
|
||||||
FROM node:latest AS frontend-builder
|
|
||||||
|
|
||||||
# Set the Current Working Directory inside the container
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the source from the current directory to the Working Directory inside the container
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# 1. Remove old build files (if present)
|
|
||||||
# 2. Set the current directory to frontend
|
|
||||||
# 3. Install dependencies
|
|
||||||
# 4. Build the frontend
|
|
||||||
RUN rm -rf frontend/dist && \
|
|
||||||
rm -rf frontend/node_modules && \
|
|
||||||
rm -f http/rice-box.go && \
|
|
||||||
cd /app/frontend && \
|
|
||||||
npm install && \
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
|
|
||||||
# Build the binary
|
|
||||||
FROM golang:alpine as binary-builder
|
|
||||||
|
|
||||||
# Set the Current Working Directory inside the container
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy go mod and sum files
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
|
|
||||||
# Copy the source from the current directory to the Working Directory inside the container
|
|
||||||
COPY --from=frontend-builder /app .
|
|
||||||
|
|
||||||
# 1. Install requirements
|
|
||||||
# 2. Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
|
|
||||||
# 3. Install dependencies
|
|
||||||
# 4. Build the Go app
|
|
||||||
RUN apk add --no-cache gcc musl-dev && \
|
|
||||||
go mod download && \
|
|
||||||
go install github.com/GeertJohan/go.rice/rice && \
|
|
||||||
cd /app/http && \
|
|
||||||
rm -rf rice-box.go && \
|
|
||||||
rice embed-go && \
|
|
||||||
cd /app && \
|
|
||||||
go build -a -o filebrowser -ldflags "-s -w"
|
|
||||||
|
|
||||||
|
|
||||||
# Add CA certificates
|
|
||||||
FROM alpine:latest AS certifier
|
|
||||||
|
|
||||||
# Install CA certificates
|
|
||||||
RUN apk --update add ca-certificates
|
RUN apk --update add ca-certificates
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
# Serve app
|
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
FROM alpine
|
|
||||||
COPY --from=certifier /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
||||||
COPY --from=binary-builder /app/filebrowser /filebrowser
|
|
||||||
|
|
||||||
VOLUME /srv
|
VOLUME /srv
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
COPY .docker.json /.filebrowser.json
|
COPY .docker.json /.filebrowser.json
|
||||||
|
COPY filebrowser /filebrowser
|
||||||
|
|
||||||
ENTRYPOINT [ "/filebrowser" ]
|
ENTRYPOINT [ "/filebrowser" ]
|
||||||
|
|||||||
53
Dockerfile.guest-build
Normal file
53
Dockerfile.guest-build
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Build the frontend
|
||||||
|
FROM node:latest AS frontend-builder
|
||||||
|
|
||||||
|
# Set the Current Working Directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the source from the current directory to the Working Directory inside the container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Cleanup and build the frontend
|
||||||
|
RUN rm -rf frontend/node_modules && \
|
||||||
|
./wizard.sh -a
|
||||||
|
|
||||||
|
|
||||||
|
# Build the binary
|
||||||
|
FROM golang:alpine as binary-builder
|
||||||
|
|
||||||
|
# Set the Current Working Directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy go mod and sum files
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
# Copy the source from the current directory to the Working Directory inside the container
|
||||||
|
COPY --from=frontend-builder /app .
|
||||||
|
|
||||||
|
# 1. Install requirements
|
||||||
|
# 2. Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
|
||||||
|
# 3. Install dependencies
|
||||||
|
# 4. Build the Go app
|
||||||
|
RUN apk add --no-cache gcc musl-dev && \
|
||||||
|
go mod download && \
|
||||||
|
./wizard.sh -c --nosha
|
||||||
|
|
||||||
|
|
||||||
|
# Add CA certificates
|
||||||
|
FROM alpine:latest AS certifier
|
||||||
|
|
||||||
|
# Install CA certificates
|
||||||
|
RUN apk --update add ca-certificates
|
||||||
|
|
||||||
|
|
||||||
|
# Serve app
|
||||||
|
FROM alpine
|
||||||
|
COPY --from=certifier /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
|
COPY --from=binary-builder /app/filebrowser /filebrowser
|
||||||
|
|
||||||
|
VOLUME /srv
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
COPY .docker.json /.filebrowser.json
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/filebrowser" ]
|
||||||
@ -2,20 +2,18 @@ version: "3.7"
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
filebrowser:
|
filebrowser:
|
||||||
build:
|
image: filebrowser:latest
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
ports:
|
ports:
|
||||||
- "5001:80"
|
- "5001:80"
|
||||||
networks:
|
networks:
|
||||||
- filebrowser-nw
|
- filebrowser-nw
|
||||||
volumes:
|
volumes:
|
||||||
- "./.docker/database/database.db:/database.db"
|
- database:/database
|
||||||
- "./.docker/sysroot:/srv"
|
- fsroot:/srv
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
update_config:
|
update_config:
|
||||||
parallelism: 2
|
parallelism: 1
|
||||||
delay: 10s
|
delay: 10s
|
||||||
restart_policy:
|
restart_policy:
|
||||||
condition: on-failure
|
condition: on-failure
|
||||||
@ -23,3 +21,6 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
filebrowser-nw:
|
filebrowser-nw:
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
database:
|
||||||
|
fsroot:
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -35,3 +35,5 @@ require (
|
|||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||||
gopkg.in/yaml.v2 v2.2.4
|
gopkg.in/yaml.v2 v2.2.4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
go 1.13
|
||||||
|
|||||||
69
wizard.sh
69
wizard.sh
@ -4,16 +4,17 @@ set -e
|
|||||||
|
|
||||||
untracked="(untracked)"
|
untracked="(untracked)"
|
||||||
REPO=$(cd $(dirname $0); pwd)
|
REPO=$(cd $(dirname $0); pwd)
|
||||||
COMMIT_SHA=$(git rev-parse --short HEAD)
|
COMMIT_SHA="true"
|
||||||
ASSETS="false"
|
ASSETS="false"
|
||||||
BINARY="false"
|
BINARY="false"
|
||||||
RELEASE=""
|
RELEASE="false"
|
||||||
|
SEMVER=""
|
||||||
|
|
||||||
debugInfo () {
|
debugInfo () {
|
||||||
echo "Repo: $REPO"
|
echo "Repo: $REPO"
|
||||||
echo "Build assets: $ASSETS"
|
echo "Build assets: $ASSETS"
|
||||||
echo "Build binary: $BINARY"
|
echo "Build binary: $BINARY"
|
||||||
echo "Release: $RELEASE"
|
echo "Release: $SEMVER"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildAssets () {
|
buildAssets () {
|
||||||
@ -43,12 +44,20 @@ buildBinary () {
|
|||||||
rice embed-go
|
rice embed-go
|
||||||
|
|
||||||
cd $REPO
|
cd $REPO
|
||||||
go build -a -o filebrowser -ldflags "-s -w -X github.com/filebrowser/filebrowser/v2/version.CommitSHA=$COMMIT_SHA"
|
CMD_VARS=""
|
||||||
|
if [ "$COMMIT_SHA" = "true" ]; then
|
||||||
|
SHA=$(git rev-parse --short HEAD)
|
||||||
|
CMD_VARS="-X github.com/filebrowser/filebrowser/v2/version.CommitSHA=$SHA"
|
||||||
|
fi
|
||||||
|
|
||||||
|
go build -a -o filebrowser -ldflags "-s -w"
|
||||||
}
|
}
|
||||||
|
|
||||||
release () {
|
release () {
|
||||||
cd $REPO
|
cd $REPO
|
||||||
|
|
||||||
|
echo "RELEASE $#"
|
||||||
|
|
||||||
echo "👀 Checking semver format"
|
echo "👀 Checking semver format"
|
||||||
|
|
||||||
if [ $# -ne 1 ]; then
|
if [ $# -ne 1 ]; then
|
||||||
@ -87,30 +96,54 @@ usage() {
|
|||||||
|
|
||||||
DEBUG="false"
|
DEBUG="false"
|
||||||
|
|
||||||
while getopts "bacr:d" o; do
|
while :; do
|
||||||
case "${o}" in
|
case $1 in
|
||||||
b)
|
-h|-\?|--help)
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-a|--assets)
|
||||||
|
ASSETS="true"
|
||||||
|
;;
|
||||||
|
-c|--compile)
|
||||||
|
BINARY="true"
|
||||||
|
;;
|
||||||
|
-b|--build)
|
||||||
ASSETS="true"
|
ASSETS="true"
|
||||||
BINARY="true"
|
BINARY="true"
|
||||||
;;
|
;;
|
||||||
a)
|
-r|--release)
|
||||||
ASSETS="true"
|
RELEASE="true"
|
||||||
|
if [ "$2" ]; then
|
||||||
|
SEMVER=$2
|
||||||
|
shift
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
c)
|
--release=?*)
|
||||||
BINARY="true"
|
RELEASE="true"
|
||||||
|
SEMVER=${1#*=}
|
||||||
;;
|
;;
|
||||||
r)
|
--release=)
|
||||||
RELEASE=${OPTARG}
|
RELEASE="true"
|
||||||
;;
|
;;
|
||||||
d)
|
-d|--debug)
|
||||||
DEBUG="true"
|
DEBUG="true"
|
||||||
;;
|
;;
|
||||||
*)
|
--nosha)
|
||||||
|
COMMIT_SHA="false"
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-?*)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
esac
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
shift $((OPTIND-1))
|
|
||||||
|
|
||||||
if [ "$DEBUG" = "true" ]; then
|
if [ "$DEBUG" = "true" ]; then
|
||||||
debugInfo
|
debugInfo
|
||||||
@ -124,6 +157,6 @@ if [ "$BINARY" = "true" ]; then
|
|||||||
buildBinary
|
buildBinary
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$RELEASE" != "" ]; then
|
if [ "$RELEASE" = "true" ]; then
|
||||||
release $RELEASE
|
release $SEMVER
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user