-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
140 lines (122 loc) · 10.3 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# ***************************************************************************************************************************************
# * Dockerfile *
# **************************************************************************************************************************************
# * *
# * @License Starts *
# * *
# * Copyright © 2023. MongoExpUser. All Rights Reserved. *
# * *
# * License: MIT - https://github.com/MongoExpUser/Ubuntu-PostgreSQL-Pgvector-Image-and-Containers/blob/main/LICENSE *
# * *
# * @License Ends *
# **************************************************************************************************************************************
# * *
# * Project: Ubuntu-Postgres-Pgvector Image & Containers Project *
# * *
# * This dockerfile creates an image based on: *
# * *
# * 1) Ubuntu Linux 22.04 *
# * *
# * 2) Additional Ubuntu Utility Packages *
# * *
# * 3) PostgreSQL v16 (Architecture: x86_64) with pgvector extension (Vector Storage & Search Capabilities) & pgcron extension *
# * *
# * 4) Python v3.x *
# * *
# * 5) Python3-pip *
# * *
# * 6) Python3 Packages: boto3, pg8000, etc. *
# * *
# * 7) Python3 Awscli Upgrade *
# * *
# * 8) Awscli v2 *
# * *
# * 9) NodeJS v21.x *
# * *
# * 10) NodeJS Packages: @aws-sdk/client-s3, pg, etc. *
# * *
# * 11) Docker 26.1: docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin *
# * *
# * 12) Files clean up *
# * *
# * *
# ***************************************************************************************************************************************
# 1a. Base Image. Version: Any of 22.04 or jammy. Ref: https://hub.docker.com/_/ubuntu
FROM ubuntu:22.04
# 1b. Labels
LABEL maintainer="MongoExpUser"
LABEL maintainer_email="MongoExpUser@domain.com"
LABEL company="MongoExpUser"
LABEL version="1.0"
# 1c. Create user(s) and add to the sudoers group
RUN apt-get -y update && apt-get -y install sudo
RUN adduser --disabled-password --gecos 'dbs-1' dbs && adduser dbs sudo
RUN adduser --disabled-password --gecos 'app-1' app && adduser app sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# 1c. Make and change to base dir
RUN cd /home/ && sudo mkdir /home/base && cd /home/base && sudo chmod 777 /home/base
# 1d. Update & Upgrade
RUN sudo apt-get -y update
RUN sudo apt-get -y upgrade
RUN sudo apt-get -y dist-upgrade
RUN sudo apt-get -y update
# 2. Additional Ubuntu Packages
RUN sudo apt-get install -y systemd apt-utils nfs-common nano unzip zip gzip
RUN sudo apt-get install -y sshpass cmdtest snap nmap net-tools wget curl tcl-tls
RUN sudo apt-get install -y iputils-ping certbot python3-certbot-apache gnupg gnupg2 telnet
RUN sudo apt-get install -y aptitude build-essential gcc make screen snapd spamc parted openssl
RUN sudo apt-get install -y systemd procps spamassassin
# 3a. Postgresql v16 (Architecture: x86_64)
RUN sudo apt-get -y update
RUN sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RUN sudo apt-get -y update
RUN sudo apt-get -y install postgresql-16
# 3b. Pgvector extension (for vector storage and search)
RUN sudo apt-get -y install postgresql-common
RUN sudo apt-get -y install curl ca-certificates
RUN sudo install -d /usr/share/postgresql-common/pgdg
RUN sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN sudo apt-get -y update
RUN sudo apt-get -y install postgresql-16-pgvector
# CREATE EXTENSION IF NOT EXISTS vector; => Add to postgres via docker compose file (docker-compose-psql.yml) or weather-ddl.sql
# 3c. Pgcron (for job scheduling)
RUN sudo apt-get -y install postgresql-16-cron
# CREATE EXTENSION IF NOT EXISTS pg_cron; => Add to postgres via docker compose file (docker-compose-psql.yml) or weather-ddl.sql
# 4. Python3.x
RUN sudo apt-get -y install python3
# 5. Python3-pip
RUN sudo apt-get -y install python3-pip
# 6. Python3 packages
RUN sudo python3 -m pip install boto3
# Note below: pyarrow requires fsspec vs. 2023.1.0
RUN sudo -H python3 -m pip install fsspec==2023.1.0 pg8000 psycopg-binary psycopg_pool sb-json-tools jupyterlab jupyterlab-night pyiceberg pyarrow psycopg2-binary sqlalchemy polars
# 7. Python3 Awscli upgrade
RUN sudo python3 -m pip install --upgrade awscli
# 8. Awscli v2 (Architecture: x86_64)
RUN sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN sudo chmod 777 awscliv2.zip
RUN sudo unzip awscliv2.zip
RUN sudo ./aws/install
# 9. Node.js v21.x
RUN sudo apt-get -y update
RUN sudo apt-get -y install ca-certificates curl gnupg
RUN sudo mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_21.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
RUN sudo apt-get -y update
RUN sudo apt-get install -y nodejs
# 10. Node.js packages
RUN npm install --prefix "/home/base" @aws-sdk/client-s3 @aws-sdk/client-ses @aws-sdk/client-sns pg sqlite3 duckdb apache-arrow nodejs-polars
# 11. Docker latest: docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
RUN sudo apt-get -y update
RUN sudo apt-get -y install apt-transport-https ca-certificates curl gnupg lsb-release
RUN sudo mkdir -m 0755 -p /etc/apt/keyrings
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN sudo apt-get -y update
RUN sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# 12. Finally, clean up files
RUN sudo rm -rf /var/lib/apt/lists/*
RUN sudo apt-get -y autoclean
RUN sudo apt-get -y autoremove