Skip to content

Commit

Permalink
refactor: Updated dockerfiles, workflows and config files to new fold…
Browse files Browse the repository at this point in the history
…er structure
  • Loading branch information
lfbrehm committed Mar 15, 2024
1 parent 4c3b0c5 commit 18023f3
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 44 deletions.
File renamed without changes.
40 changes: 32 additions & 8 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ on:

env:
# TODO: Change variable to your image's name.
IMAGE_NAME: aruna-server
IMAGE_NAME_SERVER: aruna-server
IMAGE_NAME_PROXY: aruna-data-proxy

jobs:
push:
Expand All @@ -24,11 +25,9 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME


- name: Push image to github registry
- name: Build server image
run: docker build . --file ./components/server/Dockerfile --tag $IMAGE_NAME_SERVER
- name: Push server image to github registry
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
Expand All @@ -46,5 +45,30 @@ jobs:
HARBOR_IMAGE_ID=harbor.computational.bio.uni-giessen.de/aruna/aruna-server
docker tag $IMAGE_NAME $HARBOR_IMAGE_ID:$VERSION
docker push $HARBOR_IMAGE_ID:$VERSION
docker tag $IMAGE_NAME_SERVER $HARBOR_IMAGE_ID:$VERSION
docker push $HARBOR_IMAGE_ID:$VERSION

- name: Build proxy image
run: docker build . --file ./components/data_proxy/Dockerfile --tag $IMAGE_NAME_PROXY
- name: Push proxy image to harbor registry
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION="${{ github.run_number }}"
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo "${{ secrets.HARBORPW }}" | docker login harbor.computational.bio.uni-giessen.de -u '${{ secrets.HARBORUSER }}' --password-stdin
HARBOR_IMAGE_ID=harbor.computational.bio.uni-giessen.de/aruna/arunadataproxy
docker tag $IMAGE_NAME_PROXY $HARBOR_IMAGE_ID:$VERSION
docker push $HARBOR_IMAGE_ID:$VERSION
60 changes: 38 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ license = "MIT OR Apache-2.0"
[workspace.dependencies]
ahash = "0.8.11"
anyhow = "1.0.81"
aruna-rust-api = { git = "https://github.com/ArunaStorage/rust-api.git", branch = "pre/beta12" }
aruna-rust-api = "2.0.0-beta.12"
async-channel = "2.2.0"
async-trait = "0.1.77"
aws-config = "1.1.7"
Expand Down
11 changes: 6 additions & 5 deletions components/data_proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ WORKDIR /build
RUN apk update
RUN apk upgrade
ENV RUSTFLAGS="-C target-feature=-crt-static"
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN apk add llvm cmake gcc ca-certificates libc-dev pkgconfig openssl-dev protoc protobuf-dev protobuf-dev libpq-dev musl-dev git
COPY . .
RUN cargo build --release
RUN cargo build --release -p data_proxy

FROM alpine:3.18
WORKDIR /run
RUN apk update
RUN apk upgrade
RUN apk add libgcc gcompat ca-certificates libpq
COPY --from=builder /build/target/release/aos_data_proxy .
COPY --from=builder /build/.env .
COPY --from=builder /build/src/database/schema.sql .
CMD [ "/run/aos_data_proxy" ]
COPY --from=builder /build/target/release/data_proxy .
COPY --from=builder /build/components/data_proxy/.env .
COPY --from=builder /build/components/data_proxy/src/database/schema.sql .
CMD [ "/run/data_proxy" ]
File renamed without changes.
7 changes: 4 additions & 3 deletions Dockerfile → components/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ WORKDIR /build
RUN apk update
RUN apk upgrade
ENV RUSTFLAGS="-C target-feature=-crt-static"
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN apk add llvm cmake gcc ca-certificates libc-dev pkgconfig openssl-dev protoc protobuf-dev protobuf-dev libpq-dev musl-dev git
COPY . .
RUN cargo build --release
RUN cargo build --release -p aruna_server

FROM rust:1-alpine
WORKDIR /run
RUN apk update
RUN apk upgrade
RUN apk add llvm cmake gcc ca-certificates libc-dev pkgconfig openssl-dev protoc protobuf-dev libpq-dev musl-dev git
COPY --from=builder /build/target/release/aruna_server .
COPY --from=builder /build/.env .
COPY --from=builder /build/src/database/schema.sql .
COPY --from=builder /build/components/server/.env .
COPY --from=builder /build/components/server/src/database/schema.sql .
CMD [ "/run/aruna_server" ]

10 changes: 5 additions & 5 deletions components/server/tests/common/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct ServiceBlock {
#[allow(dead_code)]
pub async fn init_database() -> Arc<Database> {
// Load env
dotenvy::from_filename(".env").unwrap();
dotenvy::from_filename("../../.env").unwrap();

// Init database connection
let db = Database::new(
Expand Down Expand Up @@ -82,7 +82,7 @@ pub async fn init_cache(db: Arc<Database>, sync: bool) -> Arc<Cache> {
#[allow(dead_code)]
pub async fn init_nats_client() -> Arc<NatsIoHandler> {
// Load env
dotenvy::from_filename(".env").unwrap();
dotenvy::from_filename("../../.env").unwrap();

// Init NatsIoHandler
let client = async_nats::connect(dotenvy::var("NATS_HOST").unwrap())
Expand All @@ -99,7 +99,7 @@ pub async fn init_nats_client() -> Arc<NatsIoHandler> {
#[allow(dead_code)]
pub async fn init_search_client() -> Arc<MeilisearchClient> {
// Load env
dotenvy::from_filename(".env").unwrap();
dotenvy::from_filename("../../.env").unwrap();

// Init MeilisearchClient
let meilisearch_client = MeilisearchClient::new(
Expand Down Expand Up @@ -182,7 +182,7 @@ pub async fn init_permission_handler(
#[allow(dead_code)]
pub async fn init_endpoint_service() -> EndpointServiceImpl {
// Load env
dotenvy::from_filename(".env").unwrap();
dotenvy::from_filename("../../.env").unwrap();

// Init database connection
let db_conn = init_database().await;
Expand Down Expand Up @@ -240,7 +240,7 @@ pub async fn init_endpoint_service() -> EndpointServiceImpl {
#[allow(dead_code)]
pub async fn init_project_service() -> ProjectServiceImpl {
// Load env
dotenvy::from_filename(".env").unwrap();
dotenvy::from_filename("../../.env").unwrap();

// Init database connection
let db_conn = init_database().await;
Expand Down

0 comments on commit 18023f3

Please sign in to comment.