Commit 0d91fb2a authored by Arturo Hernandez's avatar Arturo Hernandez

wip docker alpine [not working (yet)]

parent ca840d2f
# Pull base image
#recommended, the latest 3.8-alpine
FROM python:3.8-alpine
# Set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set work directory
WORKDIR /code
# Copy install
ADD requirements.txt /code/
# Install dependencies
RUN apk add --no-cache ccid pcsc-lite && \
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing py3-pyscard && \
pip install tornado && \
cp -r /usr/lib/python3.8/site-packages/* /usr/local/lib/python3.8/site-packages
#copy base files
run mkdir -p /code/cert/
ADD ./cert/server.crt /code/cert/
ADD ./cert/server.key /code/cert/
ADD src /code/src/
ENV LOGFILE /dev/stdout
ENV MST_PORT 8000
ENV MST_CERT cert/server.crt
ENV MST_KEY cert/server.key
ENV DEBUG False
CMD python3 src/main.py
......@@ -23,7 +23,7 @@ Construir la imagen:
Iniciar docker con acceso a usb e iniciar el monitor usb (o iniciar manualmente pcscd en el contenedor) (asegúrese de no tener el servicio de `pcscd.socket` ni `pcscd.service` habilitados en el host, ya que puede obstruir con la conexión al dispositivo en el contenedor)
```sh
docker run --rm -d -p 127.0.0.1:8000:8000 --device=/dev/bus/usb --device-cgroup-rule='c 189:* rmw' --name agetic_mst agetic_mst:1.0.0 && docker exec -t agetic_mst bash -c 'pcscd'
docker run --rm -d -p 127.0.0.1:8000:8000 --device=/dev/bus/usb --device-cgroup-rule='c 189:* rmw' --name agetic_mst agetic_mst:1.0.0 && docker exec -t agetic_mst sh -c 'pcscd'
# luego iniciar el monitor USB (permite reconectar)
./refresh_usb.sh # requiere python
......
#!/bin/bash
#!/usr/bin/env bash
IMAGE_NAME="agetic_mst"
SRC=$(cd $(dirname "$0"); cd ..; pwd)
cd $SRC
echo "WIP: dockerfile_alpine doesn't work, conflict within pyscard and bundled pcscd"
exit
#docker ps -a | awk '{ print $1,$2 }' | grep sedem_mst:1.0.0 | awk '{print $1 }' | xargs -I {} docker rm {}
docker ps -a | grep "${IMAGE_NAME}:1.0.0" | awk '{print $1}' | xargs docker rm
#docker rmi zkcluster
docker images -a | grep "${IMAGE_NAME}" | awk '{print $3}' | xargs docker rmi
docker build -t "${IMAGE_NAME}":1.0.0 -f docker/Dockerfile_alpine .
......@@ -13,9 +13,9 @@ def log(message):
def exec_in_container(cmd, name="agetic_mst"):
log( "docker exec {} bash -c '{}'".format(name, cmd))
log( "docker exec {} sh -c '{}'".format(name, cmd))
return subprocess.check_output(
"docker exec {} bash -c '{}'".format(name, cmd),
"docker exec {} sh -c '{}'".format(name, cmd),
universal_newlines=True,
shell=True
)
......
......@@ -12,15 +12,15 @@ idString="${idVendor}:${idProduct}"
devWasConnected=$(lsusb | grep "ID ${idString}" | wc -l)
./docker-usb-sync.py
docker exec -t agetic_mst bash -c 'killall pcscd'
docker exec -t agetic_mst bash -c 'pcscd'
docker exec -t agetic_mst sh -c 'killall pcscd'
docker exec -t agetic_mst sh -c 'pcscd'
inotifywait -r -m /dev/bus/usb -e CREATE -e DELETE | while read e
do
#echo $e
./docker-usb-sync.py
echo "restarting pcscd..."
docker exec -t agetic_mst bash -c 'killall pcscd'
docker exec -t agetic_mst bash -c 'pcscd'
docker exec -t agetic_mst sh -c 'killall pcscd'
docker exec -t agetic_mst sh -c 'pcscd'
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment