-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
239 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM ubuntu:24.04 | ||
|
||
ARG MF_CLIENT_URL=https://gitlab.unimelb.edu.au/resplat-mediaflux/releases/raw/master/mediaflux/unimelb-mf-clients-0.7.9-linux-x64.tar.gz | ||
ARG AWS_CLI_URL=https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
wget unzip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
|
||
RUN wget $MF_CLIENT_URL \ | ||
&& tar -xzf unimelb-mf-clients-0.7.9-linux-x64.tar.gz \ | ||
&& rm unimelb-mf-clients-0.7.9-linux-x64.tar.gz \ | ||
&& mv * mf | ||
|
||
|
||
RUN <<EOF | ||
for i in mf/bin/unix/unimelb-mf-*; do | ||
name=$(basename $i | sed 's/unimelb-mf-//') | ||
ln -s $i $name | ||
done | ||
EOF | ||
|
||
RUN cd /tmp && \ | ||
wget $AWS_CLI_URL && \ | ||
unzip awscli-exe-linux-x86_64.zip && \ | ||
./aws/install && \ | ||
rm -rf /tmp/awscli-exe-linux-x86_64.zip /tmp/aws | ||
|
||
|
||
# NOTE: https://gitlab.unimelb.edu.au/resplat-mediaflux/unimelb-mf-clients/-/blob/master/README.md#system-environment-variables | ||
ENV MFLUX_HOST=mediaflux.researchsoftware.unimelb.edu.au | ||
ENV MFLUX_PORT=443 | ||
ENV MFLUX_DOMAIN=local | ||
|
||
ENV MFLUX_TRANSPORT=https | ||
|
||
COPY archive.sh /app/archive.sh | ||
RUN chmod +x /app/archive.sh | ||
|
||
CMD ["/app/archive.sh"] |
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,20 @@ | ||
#!/bin/bash | ||
|
||
echo "$@" | ||
|
||
if [ -z "$S3_BUCKET" ] || [ -z "$S3_KEY" ]; then | ||
echo "Error: S3_BUCKET and S3_KEY environment variables must be set" | ||
exit 1 | ||
fi | ||
|
||
# Download file from S3 to /tmp | ||
if ! aws s3 cp "s3://${S3_BUCKET}/${S3_KEY}" /tmp/downloaded_file; then | ||
echo "Error: Failed to download file from S3" | ||
exit 1 | ||
fi | ||
|
||
# Process the downloaded file with MediaFlux script | ||
/app/upload --dest "/projects/proj-1190_paradisec_backup-1128.4.248/TEST/$S3_KEY" --create-parents /tmp/downloaded_file | ||
|
||
# Remove the downloaded file | ||
rm /tmp/downloaded_file |
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,81 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import type { Construct } from 'constructs'; | ||
|
||
import * as s3 from 'aws-cdk-lib/aws-s3'; | ||
|
||
import type { Environment } from './types'; | ||
import { NagSuppressions } from 'cdk-nag'; | ||
|
||
export class DrStack extends cdk.Stack { | ||
public drBucket: s3.IBucket; | ||
|
||
constructor(scope: Construct, id: string, environment: Environment, props?: cdk.StackProps) { | ||
super(scope, id, props); | ||
|
||
const { | ||
appName, | ||
// account, | ||
region, | ||
env, | ||
} = environment; | ||
|
||
if (env !== 'prod') { | ||
throw new Error('DR stack can only be deployed to prod'); | ||
} | ||
if (region !== 'ap-southeast-4') { | ||
console.log(region); | ||
throw new Error('DR stack can only be deployed to ap-southeast-4'); | ||
} | ||
|
||
// //////////////////////// | ||
// DR Meta Bucket | ||
// //////////////////////// | ||
const metaDrBucket = new s3.Bucket(this, 'MetaBucket', { | ||
bucketName: `${appName}-metadr-${env}`, | ||
encryption: s3.BucketEncryption.S3_MANAGED, | ||
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, | ||
enforceSSL: true, | ||
removalPolicy: cdk.RemovalPolicy.RETAIN, | ||
}); | ||
NagSuppressions.addResourceSuppressions(metaDrBucket, [ | ||
{ id: 'AwsSolutions-S1', reason: "This bucket holds logs for other buckets and we don't want a loop" }, | ||
]); | ||
|
||
// //////////////////////// | ||
// Dr bucket | ||
// //////////////////////// | ||
|
||
this.drBucket = new s3.Bucket(this, 'DrBucket', { | ||
bucketName: `${appName}-catalogdr-${env}`, | ||
encryption: s3.BucketEncryption.S3_MANAGED, | ||
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, | ||
enforceSSL: true, | ||
lifecycleRules: [{ abortIncompleteMultipartUploadAfter: cdk.Duration.days(7) }], | ||
versioned: env === 'prod', | ||
inventories: [ | ||
{ | ||
destination: { | ||
bucket: metaDrBucket, | ||
prefix: 'inventories/catalogdr', | ||
}, | ||
frequency: s3.InventoryFrequency.WEEKLY, | ||
includeObjectVersions: s3.InventoryObjectVersion.ALL, | ||
optionalFields: [ | ||
'Size', | ||
'LastModifiedDate', | ||
'StorageClass', | ||
'ReplicationStatus', | ||
'IntelligentTieringAccessTier', | ||
'ChecksumAlgorithm', | ||
'ETag', | ||
], | ||
}, | ||
], | ||
removalPolicy: cdk.RemovalPolicy.RETAIN, | ||
serverAccessLogsBucket: metaDrBucket, | ||
serverAccessLogsPrefix: `s3-access-logs/${appName}-catalogdr-${env}`, | ||
}); | ||
|
||
cdk.Tags.of(this).add('uni:billing:application', 'para'); | ||
} | ||
} |
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