forked from COATnor/coat2pycsw
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update REAME and .env.example
- Loading branch information
Showing
10 changed files
with
217 additions
and
10 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 |
---|---|---|
|
@@ -9,4 +9,5 @@ log/* | |
metadata/* | ||
!metadata/README.md | ||
samples | ||
.env | ||
.env | ||
.pdm-python |
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,17 @@ | ||
#!/bin/bash | ||
echo "[00_load_envvars] Loading environment variables..." | ||
set -o allexport | ||
# Convert .env line endings to Unix style | ||
sed -i 's/\r$//' .env | ||
source <(grep -v '^#' .env | xargs -0) | ||
set +o allexport | ||
|
||
# Add environment variables to .bashrc | ||
while IFS= read -r line | ||
do | ||
if [[ ! $line =~ ^# && $line = *[!\ ]* ]]; then | ||
echo "export $line" >> $HOME/.bashrc | ||
fi | ||
done < .env | ||
|
||
echo "[00_load_envvars] Environment variables loaded." |
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,24 @@ | ||
version: '3' | ||
|
||
services: | ||
ckan2pycsw_test: | ||
container_name: ${CONTAINER_OS_NAME} | ||
build: | ||
context: . | ||
dockerfile: docker/${CONTAINER_OS}/${CONTAINER_OS}-${CONTAINER_OS_VERSION}/Dockerfile | ||
env_file: | ||
- .env | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "100m" | ||
max-file: "10" | ||
ports: | ||
- ${PYCSW_HOST_PORT}:${PYCSW_PORT} | ||
- ${SSH_HOST_PORT}:${SSH_PORT} | ||
volumes: | ||
- ./log:${APP_DIR}/ckan-pycsw/log | ||
- ./metadata:${APP_DIR}/ckan-pycsw/metadata | ||
networks: | ||
default: | ||
name: ckan2pycsw-test |
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,24 @@ | ||
# ckan-pycsw testing Environments | ||
This repository contains a `docker` directory with various Dockerfiles for different environments such as RHEL, SUSE, Debian, etc. These Dockerfiles are designed to test the `ckan-pycsw` software in a clean, isolated, and volatile environment. | ||
|
||
## Why Docker? | ||
Docker allows us to create lightweight and isolated environments, known as containers, where we can run our software with all its dependencies. This makes it easy to test our software in different environments without having to install and configure each environment manually. | ||
|
||
## What is ckan-pycsw? | ||
`ckan-pycsw` is a software that allows CKAN data portals to publish metadata to CSW catalogs. It is written in Python 3. | ||
|
||
## How to use these Dockerfiles? | ||
To use these Dockerfiles, you need to have Docker installed on your machine. Once you have Docker installed, you can build a Docker image for a specific environment and run a container from that image. | ||
|
||
Here is an example of how to build a Docker image for Debian and run a container from that image: | ||
|
||
```bash | ||
# Edit .env vars and select OS | ||
vi .env | ||
|
||
# To build the images: | ||
docker compose -f docker-compose.test-docker.yml build | ||
|
||
# To start the container: | ||
docker compose -f docker-compose.test-docker.yml up | ||
``` |
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,59 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi:latest | ||
LABEL maintainer="mjanez" \ | ||
name="ckan-pycsw" \ | ||
version="rhel-8" | ||
|
||
# Set up environment variables | ||
ENV PYCSW_PORT=8000 | ||
ENV CKAN_USER=ckan | ||
ENV CKAN_GROUP=ckan | ||
ENV CKAN_USER_SSH_PWD=ckan | ||
ENV SSH_PORT=22 | ||
ENV APP_DIR=/app | ||
|
||
# Install necessary packages and install Ansible | ||
RUN dnf update -y && \ | ||
# Basic packages | ||
dnf -y install sudo nano git wget gcc openssh-server openssl-devel libffi-devel make automake cmake \ | ||
# Python dependencies | ||
python3 python3-pip libpq && \ | ||
dnf clean all && \ | ||
# Update pip | ||
pip3 install --upgrade pip && \ | ||
# Install Ansible | ||
pip3 install --no-cache-dir virtualenv && \ | ||
pip3 install --no-cache-dir ansible && \ | ||
# Create ckan user/group with sudo access | ||
groupadd -g 92 ckan && \ | ||
useradd -u 92 -m -d /home/ckan -s /bin/bash -g ckan ckan && \ | ||
echo "ckan:${CKAN_USER_SSH_PWD}" | chpasswd && \ | ||
echo "ckan ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/ckan && \ | ||
chmod 0440 /etc/sudoers.d/ckan && \ | ||
# Clean up | ||
dnf clean all | ||
|
||
# SSH setup | ||
RUN mkdir /var/run/sshd && \ | ||
# Configure SSH for non-root public key authentication | ||
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ | ||
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \ | ||
# Generate host keys | ||
ssh-keygen -A | ||
|
||
# Copy the public key | ||
RUN if [ -f .ssh/keys/ssh.pub ]; then \ | ||
cp .ssh/keys/ssh.pub /home/ckan/.ssh/authorized_keys && \ | ||
chown ckan:ckan /home/ckan/.ssh/authorized_keys && \ | ||
chmod 600 /home/ckan/.ssh/authorized_keys; \ | ||
fi | ||
|
||
# Clone the git repository | ||
RUN git clone https://github.com/mjanez/ckan-pycsw ${APP_DIR} | ||
|
||
# Assign all of app_dir to the ckan user | ||
RUN chown -R ${CKAN_USER}:${CKAN_GROUP} ${APP_DIR} | ||
|
||
EXPOSE ${PYCSW_PORT} ${SSH_PORT} | ||
|
||
# Keep container running starts SSHD | ||
CMD ["/usr/sbin/sshd", "-D"] |
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,59 @@ | ||
FROM registry.access.redhat.com/ubi9/ubi:latest | ||
LABEL maintainer="mjanez" \ | ||
name="ckan-pycsw" \ | ||
version="rhel-9" | ||
|
||
# Set up environment variables | ||
ENV PYCSW_PORT=8000 | ||
ENV CKAN_USER=ckan | ||
ENV CKAN_GROUP=ckan | ||
ENV CKAN_USER_SSH_PWD=ckan | ||
ENV SSH_PORT=22 | ||
ENV APP_DIR=/app | ||
|
||
# Install necessary packages and install Ansible | ||
RUN dnf update -y && \ | ||
# Basic packages | ||
dnf -y install sudo nano git wget gcc openssh-server openssl-devel libffi-devel make automake cmake \ | ||
# Python dependencies | ||
python3 python3-pip libpq && \ | ||
dnf clean all && \ | ||
# Update pip | ||
pip3 install --upgrade pip && \ | ||
# Install Ansible | ||
pip3 install --no-cache-dir virtualenv && \ | ||
pip3 install --no-cache-dir ansible && \ | ||
# Create ckan user/group with sudo access | ||
groupadd -g 92 ckan && \ | ||
useradd -u 92 -m -d /home/ckan -s /bin/bash -g ckan ckan && \ | ||
echo "ckan:${CKAN_USER_SSH_PWD}" | chpasswd && \ | ||
echo "ckan ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/ckan && \ | ||
chmod 0440 /etc/sudoers.d/ckan && \ | ||
# Clean up | ||
dnf clean all | ||
|
||
# SSH setup | ||
RUN mkdir /var/run/sshd && \ | ||
# Configure SSH for non-root public key authentication | ||
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ | ||
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \ | ||
# Generate host keys | ||
ssh-keygen -A | ||
|
||
# Copy the public key | ||
RUN if [ -f .ssh/keys/ssh.pub ]; then \ | ||
cp .ssh/keys/ssh.pub /home/ckan/.ssh/authorized_keys && \ | ||
chown ckan:ckan /home/ckan/.ssh/authorized_keys && \ | ||
chmod 600 /home/ckan/.ssh/authorized_keys; \ | ||
fi | ||
|
||
# Clone the git repository | ||
RUN git clone https://github.com/mjanez/ckan-pycsw ${APP_DIR} | ||
|
||
# Assign all of app_dir to the ckan user | ||
RUN chown -R ${CKAN_USER}:${CKAN_GROUP} ${APP_DIR} | ||
|
||
EXPOSE ${PYCSW_PORT} ${SSH_PORT} | ||
|
||
# Keep container running starts SSHD | ||
CMD ["/usr/sbin/sshd", "-D"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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