Skip to content

Commit

Permalink
Try and make collab deploys faster
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Feb 13, 2024
1 parent e9b95fd commit 166e89d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 43 deletions.
9 changes: 0 additions & 9 deletions .dockerignore

This file was deleted.

29 changes: 15 additions & 14 deletions .github/workflows/deploy_collab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
tags:
- collab-production
- collab-staging
branches:
- collab-deploys

env:
DOCKER_BUILDKIT: 1
Expand Down Expand Up @@ -54,26 +56,26 @@ jobs:
- style
- tests
runs-on:
- self-hosted
- deploy
- ubuntu-latest
steps:
- name: Add Rust to the PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Sign into DigitalOcean docker registry
run: doctl registry login

- name: Prune Docker system
run: docker system prune --filter 'until=720h' -f

- name: Checkout repo
uses: actions/checkout@v4
with:
clean: false
submodules: "recursive"
fetch-depth: 0

- name: build collab
shell: bash -euxo pipefail {0}
run: |
export CARGO_PROFILE_RELEASE_PANIC=abort
cargo build --release --package collab --bin collab
- name: Build docker image
run: docker build . --build-arg GITHUB_SHA=$GITHUB_SHA --tag registry.digitalocean.com/zed/collab:$GITHUB_SHA
run: docker build . --tag registry.digitalocean.com/zed/collab:$GITHUB_SHA

- name: Sign into DigitalOcean docker registry
run: doctl registry login

- name: Publish docker image
run: docker push registry.digitalocean.com/zed/collab:${GITHUB_SHA}
Expand All @@ -83,8 +85,7 @@ jobs:
needs:
- publish
runs-on:
- self-hosted
- deploy
- ubuntu-latest

steps:
- name: Sign into Kubernetes
Expand Down
23 changes: 3 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
# syntax = docker/dockerfile:1.2

FROM rust:1.76-bullseye as builder
WORKDIR app
COPY . .

# Compile collab server
ARG CARGO_PROFILE_RELEASE_PANIC=abort
ARG GITHUB_SHA

ENV GITHUB_SHA=$GITHUB_SHA
RUN --mount=type=cache,target=./script/node_modules \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=./target \
cargo build --release --package collab --bin collab

# Copy collab server binary out of cached directory
RUN --mount=type=cache,target=./target \
cp /app/target/release/collab /app/collab

# Copy collab server binary to the runtime image
FROM debian:bullseye-slim as runtime
RUN apt-get update; \
apt-get install -y --no-install-recommends libcurl4-openssl-dev ca-certificates
COPY ./target/release/collab /app/collab
COPY ./crates/collab/migrations /app/migrations

WORKDIR app
COPY --from=builder /app/collab /app/collab
COPY --from=builder /app/crates/collab/migrations /app/migrations
ENV MIGRATIONS_PATH=/app/migrations
ENTRYPOINT ["/app/collab"]

0 comments on commit 166e89d

Please sign in to comment.