Made builder root again
continuous-integration/drone the build was successful Details

pull/43/head
Jef Roosens 2021-04-24 09:47:28 +02:00
parent 0abfaca967
commit 3bdf79e824
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
2 changed files with 15 additions and 18 deletions

View File

@ -2,7 +2,7 @@
# Our entire toolchain runs in alpine
FROM alpine:3.13.5 AS builder
ENV PATH "$PATH:/app/.cargo/bin"
ENV PATH "$PATH:/root/.cargo/bin"
# Needed for proper compiling of openssl-dev
ENV RUSTFLAGS "-C target-feature=-crt-static"
@ -19,13 +19,7 @@ RUN addgroup -S builder && \
openssl-dev \
postgresql-dev
# Switch to the non-root user
USER builder
WORKDIR /app
# Install rustup in the new user's home
# Create mountpoints for volumes with correct permissions
RUN { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly; } && \
rustup target add x86_64-unknown-linux-musl --toolchain nightly && \
mkdir -p .cargo/registry target
rustup target add x86_64-unknown-linux-musl --toolchain nightly

23
fejctl
View File

@ -18,16 +18,6 @@ function dc() {
done
shift $((OPTIND-1))
if [[ "$build_builder" -eq 1 ]]; then
# We always rebuild the builder before we run any compose command
DOCKER_BUILDKIT=1 docker build \
-f docker/Dockerfile.builder \
-t "$image-builder:latest" . || {
>&2 echo "Failed to build builder.";
exit 1;
}
fi
if [[ "$release" -eq 1 ]]; then
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose \
--file docker/docker-compose.yml \
@ -53,6 +43,18 @@ function dcr() {
--detach
}
# Publish the builder image
function publish_builder() {
DOCKER_BUILDKIT=1 docker build \
-f docker/Dockerfile.builder \
-t "$image-builder:latest" . || {
>&2 echo "Failed to build builder.";
exit 1;
}
docker push "$image-builder:latest"
}
# Tags & pushes the release version to Docker Hub
function publish() {
local branch=`git rev-parse --abbrev-ref HEAD`
@ -113,6 +115,7 @@ function main() {
l | logs ) dc -- logs -f app ;;
lint ) cargo fmt -- --check ;;
p | push | publish ) publish ;;
pb ) publish_builder ;;
t | test ) dcr -- test --no-fail-fast && dc -- logs -f app ;;
* ) >&2 echo "Invalid command."; exit 1 ;;
esac