Skip to content
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
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Node.js
webapp/node_modules/
webapp/build/

# Go
vendor/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed, otherwise build-static.sh will fail. As the build commands there use -mod vendor


# IDE
.vscode/
.idea/

# Build artifacts
bin/
dist/

# Test artifacts
coverage/

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ debug.html
git_push.sh
webapp/src/lib/api/generated/docs
.env

# Compiled webapp assets (built during Docker build)
webapp/assets/_app/
webapp/assets/assets/
webapp/assets/index.html
webapp/assets/*.png
webapp/build/
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Stage 1: Build webapp
FROM docker.io/node:lts-alpine AS webapp

WORKDIR /build/webapp
COPY webapp/package.json webapp/package-lock.json ./
RUN npm ci
COPY webapp/ ./
RUN npm run build

# Stage 2: Build Go binaries
FROM docker.io/golang:alpine AS builder
ARG GARM_REF

Expand All @@ -10,6 +20,10 @@ RUN echo ${GARM_REF}
ADD . /build/garm

RUN git -C /build/garm checkout ${GARM_REF}

# Copy webapp build output to assets directory (after git checkout to override any checked-in assets)
COPY --from=webapp /build/webapp/build/ /build/garm/webapp/assets/

RUN cd /build/garm \
&& go build -o /bin/garm \
-tags osusergo,netgo,sqlite_omit_load_extension \
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile.build-static
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Stage 1: Build webapp
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Dockerfile was initially written to be built once and reused many times by just creating a new temporary container from it and running the build-static.sh script. But given that we might need to also build and copy the webapp now, I think we can expand it a bit more and just run docker build to get the static binary. See bellow comments.

FROM docker.io/node:lts-alpine AS webapp

WORKDIR /build/webapp
COPY webapp/package.json webapp/package-lock.json ./
RUN npm ci
COPY webapp/ ./
RUN npm run build

# Stage 2: Build Go binaries
FROM docker.io/golang:alpine

WORKDIR /root
Expand All @@ -14,4 +24,7 @@ RUN chmod +x /build-static.sh

ADD . /build/garm

# Copy webapp build output to assets directory
COPY --from=webapp /build/webapp/build/ /build/garm/webapp/assets/

CMD ["/bin/sh"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can replace this with

Suggested change
CMD ["/bin/sh"]
ARG GARM_REF=""
ENV GARM_REF=${GARM_REF}
RUN /build-static.sh
# Stage 3: Export only the binaries
FROM scratch AS export
COPY --from=builder /build/output/ /
CMD ["/bin/sh"]

See the Makefile comment for the last bit.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ build: ## Build garm
@echo Binaries are available in $(PWD)/bin

.PHONY: build-webui
build-webui:
build-webui: ## Build GARM web UI (for local development)
@echo Building GARM web ui
./build-webapp.sh
rm -rf webapp/assets/_app
./scripts/build-webapp.sh
rm -rf webapp/assets/_app webapp/assets/assets webapp/assets/index.html webapp/assets/*.png
cp -r webapp/build/* webapp/assets/

.PHONY: generate
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion webapp/assets/_app/env.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/assets/0.Dm58_Ye1.css

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/4L8NSMkU.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/7XD7ITBY.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/B-bv0ihJ.js

This file was deleted.

2 changes: 0 additions & 2 deletions webapp/assets/_app/immutable/chunks/BDUel5dG.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/BZiHL9L3.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/Bbk4dQfI.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/BcoJ4GZv.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/Bi2FJHrT.js

This file was deleted.

2 changes: 0 additions & 2 deletions webapp/assets/_app/immutable/chunks/Bje4SFZN.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/BqCROW90.js

This file was deleted.

1 change: 0 additions & 1 deletion webapp/assets/_app/immutable/chunks/BtzOUN4g.js

This file was deleted.

Loading
Loading