Skip to content

Commit

Permalink
Adds dev container
Browse files Browse the repository at this point in the history
  • Loading branch information
aykut-bozkurt committed Oct 8, 2024
1 parent 58c409e commit b6f7d0b
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND="noninteractive"
ENV TZ="Europe/Istanbul"

ARG PG_MAJOR=17

# install deps
RUN apt-get update && apt-get -y install build-essential libreadline-dev zlib1g-dev \
flex bison libxml2-dev libxslt-dev libssl-dev \
libxml2-utils xsltproc ccache pkg-config wget \
curl lsb-release sudo nano net-tools git awscli

# install Postgres
RUN 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 | apt-key add -
RUN apt-get update && apt-get -y install postgresql-${PG_MAJOR}-postgis-3 \
postgresql-server-dev-${PG_MAJOR} \
postgresql-client-${PG_MAJOR} \
libpq-dev

# download and install MinIO server and client
RUN wget https://dl.min.io/server/minio/release/linux-amd64/minio
RUN chmod +x minio
RUN mv minio /usr/local/bin/minio

# download and install MinIO admin
RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc
RUN chmod +x mc
RUN mv mc /usr/local/bin/mc

# set up pgrx with non-sudo user
ARG USERNAME=rust
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -s /bin/bash -m $USERNAME

RUN mkdir /workspaces && chown -R $USER_UID:$USER_GID /workspaces

# set up permissions so that the user below can create extensions
RUN chmod a+rwx `pg_config --pkglibdir` \
`pg_config --sharedir`/extension \
/var/run/postgresql/

# add it to sudoers
RUN echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME

# now it is time to switch to user
USER $USERNAME

# install Rust environment
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
ENV PATH="/home/rust/.cargo/bin:${PATH}"

# install and configure pgrx
ARG PGRX_VERSION=0.12.5
RUN cargo install --locked cargo-pgrx@${PGRX_VERSION}
RUN cargo pgrx init --pg${PG_MAJOR} $(which pg_config)
RUN echo "shared_preload_libraries = 'pg_parquet'" >> $HOME/.pgrx/data-${PG_MAJOR}/postgresql.conf

ENV MINIO_ROOT_USER=admin
ENV MINIO_ROOT_PASSWORD=admin123
ENV AWS_S3_TEST_BUCKET=testbucket
ENV AWS_REGION=us-east-1
ENV AWS_ACCESS_KEY_ID=admin
ENV AWS_SECRET_ACCESS_KEY=admin123
ENV PG_PARQUET_TEST=true
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"vadimcn.vscode-lldb",
"GitHub.copilot",
"eamodio.gitlens",
"bradymholt.pgformatter",
"rust-lang.rust-analyzer",
"ms-vscode.cpptools",
"henriiik.docker-linter"
]
}
},
"postStartCommand": "bash .devcontainer/scripts/setup-minio.sh",
"forwardPorts": [
5432
],
"capAdd": [
"SYS_PTRACE"
]
}
7 changes: 7 additions & 0 deletions .devcontainer/scripts/setup-minio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

nohup minio server /tmp/minio-storage > /dev/null 2>&1 &

mc alias set local http://localhost:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD

aws --endpoint-url http://localhost:9000 s3 mb s3://testbucket

0 comments on commit b6f7d0b

Please sign in to comment.