forked from vieter-v/vieter
Merge pull request 'Merge dockerfiles' (#102) from builder-fix into dev
Reviewed-on: Chewing_Bever/vieter#102main
commit
6d3ff8ad08
|
@ -5,6 +5,8 @@ data/
|
|||
vieter
|
||||
dvieter
|
||||
pvieter
|
||||
dvieterctl
|
||||
vieterctl
|
||||
vieter.c
|
||||
|
||||
# Ignore testing files
|
||||
|
|
|
@ -9,7 +9,6 @@ pipeline:
|
|||
secrets: [ docker_username, docker_password ]
|
||||
settings:
|
||||
repo: chewingbever/vieter
|
||||
dockerfile: Dockerfile.ci
|
||||
tag: dev
|
||||
platforms: [ linux/arm/v7, linux/arm64/v8, linux/amd64 ]
|
||||
build_args_from_env:
|
||||
|
@ -23,7 +22,6 @@ pipeline:
|
|||
secrets: [ docker_username, docker_password ]
|
||||
settings:
|
||||
repo: chewingbever/vieter
|
||||
dockerfile: Dockerfile.ci
|
||||
auto_tag: true
|
||||
platforms: [ linux/arm/v7, linux/arm64/v8, linux/amd64 ]
|
||||
build_args_from_env:
|
||||
|
|
49
Dockerfile
49
Dockerfile
|
@ -1,19 +1,56 @@
|
|||
FROM chewingbever/vlang:latest AS builder
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG CI_COMMIT_SHA
|
||||
ARG DI_VER=1.2.5
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Build dumb-init
|
||||
RUN curl -Lo - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \
|
||||
cd "dumb-init-${DI_VER}" && \
|
||||
make SHELL=/bin/sh && \
|
||||
mv dumb-init .. && \
|
||||
cd ..
|
||||
|
||||
# Copy over source code & build production binary
|
||||
COPY src ./src
|
||||
COPY Makefile ./
|
||||
|
||||
ENV LDFLAGS='-lz -lbz2 -llzma -lexpat -lzstd -llz4 -static'
|
||||
RUN v -o pvieter -cflags "-O3" src
|
||||
RUN if [ -n "${CI_COMMIT_SHA}" ]; then \
|
||||
curl --fail \
|
||||
-o vieter \
|
||||
"https://s3.rustybever.be/vieter/commits/${CI_COMMIT_SHA}/vieter-$(echo "${TARGETPLATFORM}" | sed 's:/:-:g')" && \
|
||||
chmod +x vieter ; \
|
||||
else \
|
||||
LDFLAGS='-lz -lbz2 -llzma -lexpat -lzstd -llz4 -static' make prod && \
|
||||
mv pvieter vieter ; \
|
||||
fi
|
||||
|
||||
|
||||
FROM alpine:3.15
|
||||
FROM busybox:1.35.0
|
||||
|
||||
ENV REPO_DIR=/data
|
||||
ENV PATH=/bin \
|
||||
VIETER_REPO_DIR=/data/repo \
|
||||
VIETER_PKG_DIR=/data/pkgs \
|
||||
VIETER_DOWNLOAD_DIR=/data/downloads \
|
||||
VIETER_REPOS_FILE=/data/repos.json
|
||||
|
||||
COPY --from=builder /app/pvieter /usr/local/bin/vieter
|
||||
COPY --from=builder /app/dumb-init /app/vieter /bin/
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/vieter" ]
|
||||
HEALTHCHECK --interval=30s \
|
||||
--timeout=3s \
|
||||
--start-period=5s \
|
||||
CMD /bin/wget --spider http://localhost:8000/health || exit 1
|
||||
|
||||
RUN mkdir /data && \
|
||||
chown -R www-data:www-data /data && \
|
||||
mkdir -p '/var/spool/cron/crontabs' && \
|
||||
echo '0 3 * * * /bin/vieter build' | crontab -
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
USER www-data:www-data
|
||||
|
||||
ENTRYPOINT ["/bin/dumb-init", "--"]
|
||||
CMD ["/bin/vieter", "server"]
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
# vim: ft=dockerfile
|
||||
# This image just has the required tools to download the binaries
|
||||
FROM chewingbever/vlang:latest AS builder
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG CI_COMMIT_SHA
|
||||
ARG DI_VER=1.2.5
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Build dumb-init
|
||||
RUN curl -Lo - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \
|
||||
cd "dumb-init-${DI_VER}" && \
|
||||
make SHELL=/bin/sh && \
|
||||
mv dumb-init .. && \
|
||||
cd ..
|
||||
|
||||
RUN curl --fail \
|
||||
-o vieter \
|
||||
"https://s3.rustybever.be/vieter/commits/${CI_COMMIT_SHA}/vieter-$(echo "${TARGETPLATFORM}" | sed 's:/:-:g')" && \
|
||||
chmod +x vieter
|
||||
|
||||
|
||||
FROM busybox:1.35.0
|
||||
|
||||
ENV PATH=/bin \
|
||||
VIETER_REPO_DIR=/data/repo \
|
||||
VIETER_PKG_DIR=/data/pkgs \
|
||||
VIETER_DOWNLOAD_DIR=/data/downloads \
|
||||
VIETER_REPOS_FILE=/data/repos.json
|
||||
|
||||
COPY --from=builder /app/dumb-init /app/vieter /bin/
|
||||
|
||||
HEALTHCHECK --interval=30s \
|
||||
--timeout=3s \
|
||||
--start-period=5s \
|
||||
CMD /bin/wget --spider http://localhost:8000/health || exit 1
|
||||
|
||||
RUN mkdir /data && \
|
||||
chown -R www-data:www-data /data && \
|
||||
mkdir -p '/var/spool/cron/crontabs' && \
|
||||
echo '0 3 * * * /bin/vieter build' >> /var/spool/cron/crontabs/www-data && \
|
||||
chown www-data:www-data /var/spool/cron/crontabs/www-data
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
USER www-data:www-data
|
||||
|
||||
ENTRYPOINT ["/bin/dumb-init", "--"]
|
||||
CMD ["/bin/vieter", "server"]
|
11
Makefile
11
Makefile
|
@ -42,6 +42,17 @@ pvieter: $(SOURCES)
|
|||
c:
|
||||
$(V) -o vieter.c $(SRC_DIR)
|
||||
|
||||
# Build the CLI tool
|
||||
.PHONY: cli
|
||||
cli: dvieterctl
|
||||
dvieterctl: cli.v
|
||||
$(V_PATH) -showcc -o dvieterctl cli.v
|
||||
|
||||
.PHONY: cli-prod
|
||||
cli-prod: vieterctl
|
||||
vieterctl: cli.v
|
||||
cli-prod:
|
||||
$(V_PATH) -showcc -o vieterctl -prod cli.v
|
||||
|
||||
# =====EXECUTION=====
|
||||
# Run the server in the default 'data' directory
|
||||
|
|
Loading…
Reference in New Issue