-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: unify local and ci docker workflows (#907)
* deps: go to 1.22.3 * removed ci dockerfile * add make buildx * updated dockerfile * ci uses make buildx command * commented upx for the future * disable openbsd/arm tests * wip * put dist file in dist path * removed unused make command * build-local to speed up local tests * don't clean when buildx * podman workaround * manually define source files for tests
- Loading branch information
Showing
12 changed files
with
113 additions
and
50 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -22,3 +22,6 @@ dist/ | |
|
||
# frontend | ||
node_modules | ||
|
||
# workaround for buildx using podman | ||
type=docker |
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 |
---|---|---|
@@ -1,19 +1,30 @@ | ||
# build stage | ||
FROM ghcr.io/ghcri/golang:1.21-alpine3.19 AS builder | ||
WORKDIR /src | ||
COPY . . | ||
RUN go build -ldflags '-s -w' | ||
# Build stage | ||
ARG ALPINE_VERSION | ||
ARG GOLANG_VERSION | ||
|
||
# server image | ||
FROM docker.io/library/alpine:${ALPINE_VERSION} AS builder | ||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ARG TARGETVARIANT | ||
COPY dist/shiori_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}/shiori /usr/bin/shiori | ||
RUN apk add --no-cache ca-certificates tzdata && \ | ||
chmod +x /usr/bin/shiori | ||
|
||
# Server image | ||
FROM scratch | ||
|
||
ENV PORT 8080 | ||
ENV SHIORI_DIR=/shiori | ||
WORKDIR ${SHIORI_DIR} | ||
|
||
LABEL org.opencontainers.image.source="https://github.com/go-shiori/shiori" | ||
LABEL maintainer="Felipe Martin <[email protected]>" | ||
|
||
COPY --from=builder /usr/bin/shiori /usr/bin/shiori | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
|
||
EXPOSE ${PORT} | ||
|
||
FROM docker.io/alpine:3.19 | ||
LABEL org.opencontainers.image.source https://github.com/go-shiori/shiori | ||
COPY --from=builder /src/shiori /usr/bin/ | ||
RUN addgroup -g 1000 shiori \ | ||
&& adduser -D -h /shiori -g '' -G shiori -u 1000 shiori | ||
USER shiori | ||
WORKDIR /shiori | ||
EXPOSE 8080 | ||
ENV SHIORI_DIR /shiori/ | ||
ENTRYPOINT ["/usr/bin/shiori"] | ||
CMD ["server"] |
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
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,30 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# Check if the shiori_builder builder exists | ||
if [ "$CONTAINER_RUNTIME" == "docker" ]; then | ||
if [ -z "$($CONTAINER_RUNTIME buildx ls | grep shiori_builder)" ]; then | ||
echo "Creating shiori_builder builder" | ||
$CONTAINER_RUNTIME buildx create --use --name shiori_builder | ||
fi | ||
fi | ||
|
||
if [[ -d "dist/shiori_linux_arm_7" ]]; then | ||
cp -r dist/shiori_linux_arm_7 dist/shiori_linux_armv7 | ||
fi | ||
|
||
if [[ -d "dist/shiori_linux_amd64_v1" ]]; then | ||
cp -r dist/shiori_linux_amd64_v1 dist/shiori_linux_amd64 | ||
fi | ||
|
||
$CONTAINER_RUNTIME buildx build \ | ||
-f ${CONTAINERFILE_NAME} \ | ||
--platform=${BUILDX_PLATFORMS} \ | ||
--build-arg "ALPINE_VERSION=${CONTAINER_ALPINE_VERSION}" \ | ||
--build-arg "GOLANG_VERSION=${GOLANG_VERSION}" \ | ||
${CONTAINER_BUILDX_OPTIONS} \ | ||
. | ||
|
||
if [ "$CONTAINER_RUNTIME" == "docker" ]; then | ||
$CONTAINER_RUNTIME buildx rm shiori_builder | ||
fi |
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