How to add TailwindCSS to Docker container? - docker

I'm trying to add TailwindCSS to Docker container but after running tailwindcss command in bash, it just says:
Traceback (most recent call last):
File "/usr/local/bin/tailwindcss", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/pytailwindcss/__main__.py", line 9, in main
completed_process = pytailwindcss.run(
File "/usr/local/lib/python3.10/site-packages/pytailwindcss/__init__.py", line 45, in run
install(version, bin_path)
File "/usr/local/lib/python3.10/site-packages/pytailwindcss/__init__.py", line 69, in install
return install_binary(version, ensure_is_pathlib_path(bin_path))
File "/usr/local/lib/python3.10/site-packages/pytailwindcss/installation.py", line 25, in install_binary
os.makedirs(bin_path.parent, exist_ok=True)
File "/usr/local/lib/python3.10/os.py", line 225, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.10/site-packages/pytailwindcss/bin
Dockerfile:
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10-bullseye
ENV PYTHONUNBUFFERED=1
WORKDIR /app
ARG FLASK_APP=project.app
ENV FLASK_APP=${FLASK_APP}
ARG FLASK_RUN_PORT=5001
ENV FLASK_RUN_PORT=${FLASK_RUN_PORT}
CMD flask run --host=0.0.0.0 # --port=${FLASK_RUN_PORT} --app=${FLASK_APP}
COPY requirements.txt /tmp/pip-tmp/
RUN pip --disable-pip-version-check install -r /tmp/pip-tmp/requirements.txt && \
rm -rf /tmp/pip-tmp
COPY . .
RUN pip --disable-pip-version-check install -v -e .
ARG CI_COMMIT_SHA
ENV CI_COMMIT_SHA=${CI_COMMIT_SHA}
RUN echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /app/.env
ARG USERNAME=vscode
RUN test ! -z "${USERNAME}" && mkdir -p /home/${USERNAME}/.vscode-server/extensions && \
chown -R $USERNAME /home/$USERNAME/.vscode-server
EDIT:
Requirements.txt
importlib-metadata
flask
python-dotenv
flask-login
passlib
flask-mongoengine
python-dateutil
pytailwindcss
pre-commit
sentry-sdk[flask]
sentry-sdk[pymongo]
Any idea how to make TailwindCSS work in a Docker container?

Related

Passing "vars" to dbt-snowflake docker container image is throwing errors

I'm running dbt-snowflake docker image and need to pass parameters while running the container. So, I tried passing --vars from the command prompt. But getting below error.
12:54:44 Running with dbt=1.3.1
12:54:45 Encountered an error:
'dbt_snowflake://macros/apply_grants.sql'
12:54:45 Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/dbt/main.py", line 135, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.10/site-packages/dbt/main.py", line 198, in handle_and_check
task, res = run_from_args(parsed)
File "/usr/local/lib/python3.10/site-packages/dbt/main.py", line 245, in run_from_args
results = task.run()
File "/usr/local/lib/python3.10/site-packages/dbt/task/runnable.py", line 453, in run
self._runtime_initialize()
File "/usr/local/lib/python3.10/site-packages/dbt/task/runnable.py", line 161, in _runtime_initialize
super()._runtime_initialize()
File "/usr/local/lib/python3.10/site-packages/dbt/task/runnable.py", line 94, in _runtime_initialize
self.load_manifest()
File "/usr/local/lib/python3.10/site-packages/dbt/task/runnable.py", line 81, in load_manifest
self.manifest = ManifestLoader.get_full_manifest(self.config)
File "/usr/local/lib/python3.10/site-packages/dbt/parser/manifest.py", line 221, in get_full_manifest
manifest = loader.load()
File "/usr/local/lib/python3.10/site-packages/dbt/parser/manifest.py", line 320, in load
self.load_and_parse_macros(project_parser_files)
File "/usr/local/lib/python3.10/site-packages/dbt/parser/manifest.py", line 422, in load_and_parse_macros
block = FileBlock(self.manifest.files[file_id])
KeyError: 'dbt_snowflake://macros/apply_grants.sql'
Below is my docker file
# Top level build args
ARG build_for=linux/amd64
##
# base image (abstract)
##
FROM --platform=$build_for python:3.10.7-slim-bullseye as base
ARG dbt_core_ref=dbt-core#v1.4.0a1
ARG dbt_postgres_ref=dbt-core#v1.4.0a1
ARG dbt_redshift_ref=dbt-redshift#v1.4.0a1
ARG dbt_bigquery_ref=dbt-bigquery#v1.4.0a1
ARG dbt_snowflake_ref=dbt-snowflake#v1.3.0
ARG dbt_spark_ref=dbt-spark#v1.4.0a1
# special case args
ARG dbt_spark_version=all
ARG dbt_third_party
# System setup
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get install -y --no-install-recommends \
git \
ssh-client \
software-properties-common \
make \
build-essential \
ca-certificates \
libpq-dev \
&& apt-get clean \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/*
# Env vars
ENV PYTHONIOENCODING=utf-8
ENV LANG=C.UTF-8
# Update python
RUN python -m pip install --upgrade pip setuptools wheel --no-cache-dir
RUN pip install -q --no-cache-dir dbt-core
RUN pip install -q --no-cache-dir dbt-snowflake
# RUN mkdir /root/.dbt
# ADD profiles.yml /root/.dbt
# Set docker basics
WORKDIR /usr/app/dbt/
VOLUME /usr/app
COPY **/profiles.yml /root/.dbt/profiles.yml
COPY . /usr/app/dbt/
ENTRYPOINT ["dbt"]
Here is my docker image docker pull madhuraju/gu-snowflake
Below is the command
docker run -it gu-snowflake:test run --vars '{"testKey": "testValue"}'
Please let me know how can I fix this issue and also how I can pass values at runtime so that dbt executes only specific models based on the values that are being passed.

Cannot run python script in Docker using chromedriver

After building the Docker file, trying to run the image when the python sript starts return this error:
Traceback (most recent call last):
File "/data/ms_rewards_farmer.py", line 815, in <module>
browser = browserSetup(True, PC_USER_AGENT)
File "/data/ms_rewards_farmer.py", line 48, in browserSetup
chrome_browser_obj = webdriver.Chrome(options=options)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line
69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line
89, in __init__
self.service.start()
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 71,
in start self.process = subprocess.Popen(cmd, env=self.env,
File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/lib/python3.9/subprocess.py", line 1823, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'chromedriver'
This is the Dockerfile:
FROM python:3.9.2
RUN mkdir -p /logs
RUN apt-get update
RUN apt install wget
RUN apt-get install -y wget xvfb unzip
# install google chrome
RUN apt-get install -y chromium
# install chromedriver
RUN wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip
RUN mv chromedriver /usr/bin/chromedriver
RUN chown root:root /usr/bin/chromedriver
RUN chmod +x /usr/bin/chromedriver
COPY . /data
WORKDIR /data
RUN pip install --no-cache-dir -r requirements.txt
# set display port to avoid crash
ENV DISPLAY=:99
# Custom Env Vars
ENV DOCKER_IMAGE=true
I don't know what's the problem, i tried to change the installation of chromedriver from the Dockerfile, any ideas?
Requirements.txt:
certifi
chardet
idna
requests
selenium
urllib3
ipapi
schedule

PermissionError: [Errno 13] Permission denied: '/app/manage.py'

I run docker-compose command and get "PermissionDenied" error. I have used the same code about 2 month ago and it worked perfectly. I have searched internet and solutions didn't help much.
docker-compose run --rm app sh -c "django-admin startproject app ."
And it gives me an error:
Traceback (most recent call last):
File "/py/bin/django-admin", line 8, in <module>
sys.exit(execute_from_command_line())
File "/py/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/py/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/py/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/py/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/py/lib/python3.9/site-packages/django/core/management/commands/startproject.py", line 21, in handle
super().handle('project', project_name, target, **options)
File "/py/lib/python3.9/site-packages/django/core/management/templates.py", line 160, in handle
with open(new_path, 'w', encoding='utf-8') as new_file:
PermissionError: [Errno 13] Permission denied: '/app/manage.py'
My Dockerfile is :
FROM python:3.9-alpine3.13
LABEL maintainer="Kananappdeveloper"
ENV PYHTONUNBUFFERED 1
COPY ./requirements.txt /tmp/requirements.txt
COPY ./requirements.dev.txt /tmp/requirements.dev.txt
COPY ./app /app
WORKDIR /app
EXPOSE 8000
ARG DEV=false
RUN python -m venv /py && \
/py/bin/pip install --upgrade pip && \
/py/bin/pip install -r /tmp/requirements.txt && \
if [ $DEV = "true" ]; \
then /py/bin/pip install -r /tmp/requirements.dev.txt ; \
fi && \
rm -rf /tmp && \
adduser \
--disabled-password \
--no-create-home \
django-user
ENV PATH="/py/bin:$PATH"
USER django-user
My OS is Ubuntu 22.04
Thank you in advance.

pip install: metadata-generation-failed in docker

This is my Dockerfile:
FROM alpine:3.14
# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
RUN apk add python3-dev # for python3.x installs
RUN apk add musl-dev
RUN apk add gcc
RUN mkdir -p /usr/src/tap-stashstock
RUN mkdir -p /usr/singer
WORKDIR /usr/src/tap-stashstock
ADD . /usr/src/tap-stashstock
ADD singer /usr/singer
RUN pip3 install --upgrade .
This works and then I run docker run -it stashstock-to-bigquery pip3 install target-bigquery which results in this error
Collecting grpcio<2.0dev,>=1.38.1
Downloading grpcio-1.44.0.tar.gz (21.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.4/21.4 MB 3.9 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-4wuwnk4b/grpcio_429c1ed72b4244a0a71ac7e9f1ec81c6/setup.py", line 256, in <module>
if check_linker_need_libatomic():
File "/tmp/pip-install-4wuwnk4b/grpcio_429c1ed72b4244a0a71ac7e9f1ec81c6/setup.py", line 203, in check_linker_need_libatomic
cpp_test = subprocess.Popen([cxx, '-x', 'c++', '-std=c++11', '-'],
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'c++'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
What am I missing from my Dockerfile?
This error may for not having a C/C++ compiler.
Try install gcc and build-essensial before pip installation.
Please follow the steps given in
https://github.com/grpc/issues/24556

when execute shell file in docker container, binary file error

I'm trying to execute shell file that contains python script.
But, I don't know why i met the error like this
file directory structure
/home/kwstat/workplace/analysis/report_me
home
kwstat
workplace
analysis
report_me
report_me.sh
python_file
python_code.py
...
$docker exec -it test /bin/bash -c "source /home/kwstat/workplace/analysis/report_me/report_me.sh"
# Error
/home/kwstat/workplace/analysis/report_me/report_me.sh: line 30: source: /usr/local/bin/python: cannot execute binary file
I tried several things in Dockerfile, But same error occured.
# 1.CMD ["/bin/bash","-l","-c"]
CMD ["/bin/bash","-l","-c"]
# 2. CMD bin/bash
CMD bin/bash
#########My Dockerfile#############
FROM continuumio/miniconda3
# System packages
RUN apt-get update && apt-get install -y curl
RUN apt-get update && apt-get install -y subversion
WORKDIR /home/kwstat/workplace/analysis/report_me
COPY environments.yml /home/kwstat/workplace/analysis/report_me/environments.yml
RUN conda env create -f /home/kwstat/workplace/analysis/report_me/environments.yml
# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"]
RUN echo "conda activate my_env" >> ~/.profile
# Activate the environment, and make sure it's activated:
#RUN echo "Make sure flask is installed:"
COPY requirements.txt /home/kwstat/me_report_dockerfile/requirements.txt
RUN pip install -r /home/kwstat/me_report_dockerfile/requirements.txt
WORKDIR /home/kwstat/workplace/analysis/report_me/python_file
COPY python_file/ /home/kwstat/workplace/analysis/report_me/python_file
WORKDIR /home/kwstat/workplace/analysis/report_me/
COPY report_me.sh ./report_me.sh
RUN chmod +x report_me.sh
CMD ["/bin/bash"]
please any help ~
my problem was from shell script.
Inside the shell set the coda env path
and all solved.

Resources