-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modelled on the Production dockerfile, but simplifies the build process. We mount the source code from the host machine and build it, then run the servers in development mode, using Air to get live-reloading in Go. Test photos are from thiscatdoesnotexist.com.
- Loading branch information
Gwyn Morfey
committed
Feb 20, 2022
1 parent
e9a4839
commit 942a2cf
Showing
8 changed files
with
179 additions
and
2 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
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,44 @@ | ||
# .air.conf | ||
# Config file for [Air](https://github.com/cosmtrek/air) in TOML format | ||
|
||
# Working directory | ||
# . or absolute path, please note that the directories following must be under root. | ||
root = "." | ||
tmp_dir = "tmp" | ||
|
||
[build] | ||
# Just plain old shell command. You could use `make` as well. | ||
cmd = "go build -o ./tmp/main server.go" | ||
# Binary file yields from `cmd`. | ||
bin = "tmp/main" | ||
# Customize binary. | ||
full_bin = "./tmp/main" | ||
# Watch these filename extensions. | ||
include_ext = ["go", "tpl", "tmpl", "html"] | ||
# Ignore these filename extensions or directories. | ||
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"] | ||
# Watch these directories if you specified. | ||
include_dir = [] | ||
# Exclude files. | ||
exclude_file = [] | ||
# It's not necessary to trigger build each time file changes if it's too frequent. | ||
delay = 1000 # ms | ||
# Stop to run old binary when build errors occur. | ||
stop_on_error = true | ||
# This log file places in your tmp_dir. | ||
log = "air_errors.log" | ||
|
||
[log] | ||
# Show log time | ||
time = false | ||
|
||
[color] | ||
# Customize each part's color. If no color found, use the raw app log. | ||
main = "magenta" | ||
watcher = "cyan" | ||
build = "yellow" | ||
runner = "green" | ||
|
||
[misc] | ||
# Delete tmp directory on exit | ||
clean_on_exit = true |
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,60 @@ | ||
# Expects /src to be mounted to the source folder (by docker-compose.yml) | ||
|
||
FROM debian:bookworm | ||
ARG TARGETPLATFORM | ||
RUN mkdir -p /development | ||
WORKDIR /development | ||
|
||
COPY ../docker/install_build_dependencies.sh /tmp/ | ||
RUN chmod +x /tmp/install_build_dependencies.sh && /tmp/install_build_dependencies.sh | ||
|
||
COPY ../docker/go_wrapper.sh /go/bin/go | ||
RUN chmod +x /go/bin/go | ||
ENV GOPATH="/go" | ||
ENV PATH="${GOPATH}/bin:${PATH}" | ||
|
||
ENV CGO_ENABLED 1 | ||
|
||
RUN go env | ||
|
||
# Download dependencies | ||
COPY ../api/go.mod ../api/go.sum /development/ | ||
RUN go mod download | ||
|
||
# Patch go-face | ||
RUN sed -i 's/-march=native//g' ${GOPATH}/pkg/mod/github.com/!kagami/go-face*/face.go | ||
|
||
# Build dependencies that use CGO | ||
RUN go install \ | ||
github.com/mattn/go-sqlite3 \ | ||
github.com/Kagami/go-face | ||
|
||
# Install tools | ||
RUN apt-get update && apt-get install -y curl procps exiftool | ||
|
||
# Setup node | ||
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - | ||
RUN apt-get update && apt-get install -y nodejs | ||
|
||
# Install Air for Go live reload | ||
RUN go get -u github.com/cosmtrek/air | ||
|
||
# Install Delve debugger | ||
RUN go install github.com/go-delve/delve/cmd/dlv@latest | ||
|
||
ENV PHOTOVIEW_LISTEN_IP localhost | ||
ENV PHOTOVIEW_LISTEN_PORT 4001 | ||
ENV REACT_APP_API_ENDPOINT http://localhost:4001/ | ||
ENV PHOTOVIEW_API_ENDPOINT http://localhost:4001/ | ||
ENV PHOTOVIEW_UI_ENDPOINT http://localhost:1234/ | ||
ENV PHOTOVIEW_SERVE_UI 0 | ||
ENV PHOTOVIEW_UI_PATH /ui | ||
ENV PHOTOVIEW_DEVELOPMENT_MODE 1 | ||
ENV COMPILER_ARCH aarch64-linux-gnu | ||
ENV ENVISSET bar | ||
EXPOSE 4001 | ||
EXPOSE 1234 | ||
|
||
COPY ../development/dev_startup.sh /development/ | ||
RUN chmod +x /development/dev_startup.sh | ||
ENTRYPOINT ["/development/dev_startup.sh"] |
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,8 @@ | ||
#!/bin/bash | ||
cd /src/ui | ||
npm install | ||
npm start & | ||
cd /src/api | ||
go install | ||
air | ||
tail -f /dev/null |
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,51 @@ | ||
version: "3" | ||
|
||
services: | ||
db: | ||
image: mariadb:10.5 | ||
restart: always | ||
environment: | ||
- MYSQL_DATABASE=photoview | ||
- MYSQL_USER=photoview | ||
- MYSQL_PASSWORD=photosecret | ||
- MYSQL_RANDOM_ROOT_PASSWORD=1 | ||
volumes: | ||
- db_data:/var/lib/mysql | ||
ports: | ||
- "3307:3306" | ||
|
||
photoview: | ||
build: | ||
context: .. | ||
dockerfile: development/Dockerfile | ||
restart: always | ||
ports: | ||
- "1234:1234" | ||
- "4001:4001" | ||
depends_on: | ||
- db | ||
|
||
environment: | ||
- PHOTOVIEW_DATABASE_DRIVER=mysql | ||
- PHOTOVIEW_MYSQL_URL=photoview:photosecret@tcp(db)/photoview | ||
- PHOTOVIEW_MEDIA_CACHE=/app/cache | ||
- PHOTOVIEW_DEVELOPMENT_MODE=1 | ||
|
||
# Optional: If you are using Samba/CIFS-Share and experience problems with "directory not found" | ||
# Enable the following Godebug | ||
# - GODEBUG=asyncpreemptoff=1 | ||
|
||
|
||
# Optional: To enable map related features, you need to create a mapbox token. | ||
# A token can be generated for free here https://account.mapbox.com/access-tokens/ | ||
# It's a good idea to limit the scope of the token to your own domain, to prevent others from using it. | ||
# - MAPBOX_TOKEN=<YOUR TOKEN HERE> | ||
|
||
volumes: | ||
- api_cache:/app/cache | ||
- ./photos:/photos:ro | ||
- ../:/src | ||
|
||
volumes: | ||
db_data: | ||
api_cache: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.