changeset 3:0ea626b10557 draft

planemo upload for repository https://github.com/afgane/gcp_batch_netcat
author enis
date Mon, 21 Jul 2025 15:13:09 +0000
parents 79160beab2a4
children 2ff4a39ea41b
files Dockerfile batch-netcat.Dockerfile gcp_batch_netcat.py
diffstat 2 files changed, 48 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Dockerfile	Tue Jul 15 21:10:05 2025 +0000
+++ b/Dockerfile	Mon Jul 21 15:13:09 2025 +0000
@@ -2,7 +2,35 @@
 
 RUN apt-get update && apt-get install -y python3 netcat-openbsd
 
-COPY gcp_batch_netcat.py /usr/bin/
-COPY gcp_batch_netcat.xml /usr/bin/
+# Create galaxy user and home directory
+RUN useradd -m -s /bin/bash galaxy
+
+# Create a directory for our scripts that galaxy user can access
+RUN mkdir -p /opt/galaxy-tools && chown galaxy:galaxy /opt/galaxy-tools
+
+# Create gcloud config directory with proper permissions
+RUN mkdir -p /home/galaxy/.config/gcloud && \
+    chown -R galaxy:galaxy /home/galaxy/.config && \
+    chmod -R 777 /home/galaxy/.config
+
+# Also create a temporary gcloud config directory as backup
+RUN mkdir -p /tmp/gcloud-config && chmod 777 /tmp/gcloud-config
 
-ENTRYPOINT ["python3", "/usr/bin/gcp_batch_netcat.py"]
+# Copy files to the galaxy-accessible directory
+COPY gcp_batch_netcat.py /opt/galaxy-tools/
+COPY gcp_batch_netcat.xml /opt/galaxy-tools/
+
+# Ensure galaxy user can execute the script
+RUN chown galaxy:galaxy /opt/galaxy-tools/* && chmod +x /opt/galaxy-tools/gcp_batch_netcat.py
+
+# Switch to galaxy user
+USER galaxy
+
+# Set environment variables for gcloud configuration
+ENV CLOUDSDK_CONFIG=/tmp/gcloud-config
+ENV HOME=/home/galaxy
+
+# Set working directory
+WORKDIR /opt/galaxy-tools
+
+ENTRYPOINT ["python3", "/opt/galaxy-tools/gcp_batch_netcat.py"]
--- a/gcp_batch_netcat.py	Tue Jul 15 21:10:05 2025 +0000
+++ b/gcp_batch_netcat.py	Mon Jul 21 15:13:09 2025 +0000
@@ -19,6 +19,12 @@
     # Set up authentication using the service account key
     os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = args.service_account_key
 
+    # Ensure gcloud uses a writable config directory
+    os.environ['CLOUDSDK_CONFIG'] = '/tmp/gcloud-config'
+
+    # Create the temp config directory if it doesn't exist
+    os.makedirs('/tmp/gcloud-config', exist_ok=True)
+
     job_name = f'netcat-job-{uuid.uuid4()}'
 
     job_spec = {
@@ -28,10 +34,17 @@
                     "runnables": [
                         {
                             "script": {
-                                "text": f"nc -z -v {args.nfs_address} {args.port}"
+                                "text": f"/usr/bin/nc -z -v {args.nfs_address} {args.port}"
                             }
                         }
-                    ]
+                    ],
+                    "computeResource": {
+                        "cpuMilli": 1000,
+                        "memoryMib": 1024
+                    },
+                    "environment": {
+                        "imageUri": "afgane/gcp-batch-netcat:0.1.0"
+                    }
                 },
                 "taskCount": 1,
                 "parallelism": 1
@@ -51,7 +64,8 @@
         '--location', args.region,
         '--project', args.project,
         '--config', job_spec_file,
-        '--format=text'
+        '--format=text',
+        '--verbosity=debug'
     ]
 
     # Wait 4 minutes before submitting the job