-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi-arch docker image support (#124)
* chore: Update Docker multi-arch build workflow * chore: Clean up old Docker images in multi-arch build workflow * Switched to use single Dockerfile configured for multi-arch * Revert "Switched to use single Dockerfile configured for multi-arch" * chore: Update readme with new instructions for cpu arch, remove Dockerfile due to migration to individual dockerfiles per arch * fix: incorrect location of arch message
- Loading branch information
1 parent
9ac7460
commit 844d154
Showing
4 changed files
with
113 additions
and
8 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
File renamed without changes.
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,64 @@ | ||
# Use official Go image for the backend build | ||
FROM golang:1.21 AS backend-builder | ||
|
||
# Install runtime dependencies (libvips) | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
libvips-dev && \ | ||
libvips=8.8.4 && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set the environment variables for the build | ||
ENV GOOS=linux | ||
ENV GOARCH=arm64 | ||
|
||
# Copy the source code and build the backend | ||
WORKDIR /app | ||
COPY go.* ./ | ||
RUN go mod download | ||
COPY . . | ||
RUN go build -ldflags "-s -w" -o discuit . | ||
|
||
# Use official Node image for the frontend build | ||
FROM node:18 AS frontend-builder | ||
|
||
# Copy required configuration files and build files | ||
WORKDIR /app | ||
COPY config.default.yaml . | ||
RUN mv config.default.yaml config.yaml | ||
COPY --from=backend-builder /app/discuit /app/discuit | ||
|
||
# Copy the source code and build the frontend | ||
WORKDIR /app/ui | ||
COPY ui/package*.json ./ | ||
RUN npm ci | ||
COPY ui/ . | ||
|
||
# Final stage: setup the runtime environment | ||
FROM node:18 | ||
# Avoid prompts from the package manager during build | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install runtime dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
mariadb-server \ | ||
redis-server \ | ||
libvips-dev && \ | ||
libvips=8.8.4 && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy built artifacts from previous stages | ||
COPY --from=frontend-builder /app/ui /app/ui | ||
COPY --from=backend-builder /app/discuit /app/discuit | ||
COPY config.default.yaml /app/config.yaml | ||
COPY migrations /app/migrations | ||
COPY docker/entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
|
||
WORKDIR /app | ||
|
||
# Setup the environment and ports | ||
EXPOSE 80 | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["/app/discuit", "serve"] |