Dockerfile For Programming Languages
1.1 Dockerfile For Programming Languages
Python
FROM python:3.9.18-bookworm
ENV USER_NON_ROOT btin
RUN pip install --upgrade pip
# Create non-root user
RUN groupadd --gid 1001 $USER_NON_ROOT \
&& adduser --shell /bin/sh --uid 1001 --gid 1001 $USER_NON_ROOT \
&& mkdir -p /app /var/log/$USER_NON_ROOT \
&& chown -R $USER_NON_ROOT:$USER_NON_ROOT /app /var/log/$USER_NON_ROOT
WORKDIR /app
USER $USER_NON_ROOT
COPY --chown=$USER_NON_ROOT:$USER_NON_ROOT requirements.txt requirements.txt
RUN pip3 install --user -r requirements.txt
ENV PATH $PATH:/home/$USER_NON_ROOT/.local/bin
COPY --chown=$USER_NON_ROOT:$USER_NON_ROOT . .
# Non-root user can not run with port < 1024
EXPOSE 8080
RUN chmod +x entrypoint.sh
CMD /app/entrypoint.sh
NodeJS
1.2 Docker Compose
Airflow
MongoDB
version: '3.8'
services:
mongodb:
image: mongo:7.0.3
container_name: btin-mongodb
ports:
- 27017:27017
environment:
- MONGO_INITDB_DATABASE=btin-mongodb
- MONGO_INITDB_ROOT_USERNAME=badmin
- MONGO_INITDB_ROOT_PASSWORD=bpassword
volumes:
- ./mongo-entrypoint:/docker-entrypoint-initdb.d
- mongodb:/data/db
- mongoconfig:/data/configdb
networks:
- mongo_net
mongo-express:
image: mongo-express:latest
restart: always
ports:
- "8081:8081"
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=badmin
- ME_CONFIG_MONGODB_ADMINPASSWORD=bpassword
- ME_CONFIG_MONGODB_SERVER=mongodb
networks:
- mongo_net
volumes:
mongodb:
mongoconfig:
networks:
mongo_net:
driver: bridge
MySQL
version: '3.8'
services:
mysqldb:
image: mysql:5.7
restart: always
command: --max_allowed_packet=1072731894
environment:
- MYSQL_DATABASE=btest
- MYSQL_ROOT_PASSWORD=bpassword
ports:
- 30306:3306
volumes:
- mysqldb:/var/lib/mysql
networks:
- mysql_net
volumes:
mysqldb:
networks:
mysql_net:
driver: bridge
PostgreSQL
version: '3.8'
services:
postgresdb:
image: postgres:12.11
ports:
- 5432:5432
env_file:
- database.env
volumes:
- postgresdb:/var/lib/postgresql/data/
networks:
- postgres_net
phppgadmin:
image: dockage/phppgadmin:latest
ports:
- "38080:80"
- "30443:443"
environment:
- PHP_PG_ADMIN_SERVER_DESC=PostgreSQL
- PHP_PG_ADMIN_SERVER_HOST=postgresdb
- PHP_PG_ADMIN_SERVER_PORT=5432
- PHP_PG_ADMIN_SERVER_SSL_MODE=allow
- PHP_PG_ADMIN_SERVER_DEFAULT_DB=template1
- PHP_PG_ADMIN_SERVER_PG_DUMP_PATH=/usr/bin/pg_dump
- PHP_PG_ADMIN_SERVER_PG_DUMPALL_PATH=/usr/bin/pg_dumpall
- PHP_PG_ADMIN_DEFAULT_LANG=auto
- PHP_PG_ADMIN_AUTO_COMPLETE=default on
- PHP_PG_ADMIN_EXTRA_LOGIN_SECURITY=false
- PHP_PG_ADMIN_OWNED_ONLY=false
- PHP_PG_ADMIN_SHOW_COMMENTS=true
- PHP_PG_ADMIN_SHOW_ADVANCED=false
- PHP_PG_ADMIN_SHOW_SYSTEM=false
- PHP_PG_ADMIN_MIN_PASSWORD_LENGTH=1
- PHP_PG_ADMIN_LEFT_WIDTH=200
- PHP_PG_ADMIN_THEME=default
- PHP_PG_ADMIN_SHOW_OIDS=false
- PHP_PG_ADMIN_MAX_ROWS=30
- PHP_PG_ADMIN_MAX_CHARS=50
- PHP_PG_ADMIN_USE_XHTML_STRICT=false
- PHP_PG_ADMIN_HELP_BASE=http://www.postgresql.org/docs/%s/interactive/
- PHP_PG_ADMIN_AJAX_REFRESH=3
networks:
- postgres_net
volumes:
postgresdb:
networks:
postgres_net:
driver: bridge