Files
pgbackweb/docker/Dockerfile.dev
Luis Eduardo Jeréz Girón ae6555c6b2 Add air for hot reload
2024-09-05 23:55:33 -06:00

81 lines
2.9 KiB
Docker

# To make sure we have the node, and golang binaries
FROM node:20.17.0-bookworm AS node
FROM golang:1.23.1-bookworm AS golang
# Set the base image, general environment variables, and move to temp dir
FROM debian:12.7
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH="$PATH:/usr/local/go/bin"
WORKDIR /app/temp
# Copy node binaries
COPY --from=node /usr/local/bin/ /usr/local/bin/
COPY --from=node /usr/local/include/ /usr/local/include/
COPY --from=node /usr/local/lib/ /usr/local/lib/
COPY --from=node /usr/local/share/ /usr/local/share/
# Copy the golang binaries
COPY --from=golang /usr/local/go /usr/local/go
ENV PATH="$PATH:/usr/local/go/bin"
# Add PostgreSQL repository - https://www.postgresql.org/download/linux/debian/
RUN apt update && apt install -y postgresql-common=248 && \
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
# Install system dependencies and PostgreSQL clients
RUN apt update && \
apt install -y \
wget=1.21.3-1+b2 unzip=6.0-28 tzdata=2024a-0+deb12u1 \
postgresql-client-13 postgresql-client-14 \
postgresql-client-15 postgresql-client-16 && \
rm -rf /var/lib/apt/lists/*
# Install downloadable binaries
RUN \
# Install task
wget --no-verbose https://github.com/go-task/task/releases/download/v3.38.0/task_linux_amd64.tar.gz && \
tar -xzf task_linux_amd64.tar.gz && \
mv ./task /usr/local/bin/task && \
chmod +x /usr/local/bin/task && \
# Install goose
wget --no-verbose https://github.com/pressly/goose/releases/download/v3.22.0/goose_linux_x86_64 && \
mv ./goose_linux_x86_64 /usr/local/bin/goose && \
chmod +x /usr/local/bin/goose && \
# Install sqlc
wget --no-verbose https://github.com/sqlc-dev/sqlc/releases/download/v1.27.0/sqlc_1.27.0_linux_amd64.tar.gz && \
tar -xzf sqlc_1.27.0_linux_amd64.tar.gz && \
mv ./sqlc /usr/local/bin/sqlc && \
chmod +x /usr/local/bin/sqlc && \
# Install golangci-lint
wget --no-verbose https://github.com/golangci/golangci-lint/releases/download/v1.60.3/golangci-lint-1.60.3-linux-amd64.tar.gz && \
tar -xzf golangci-lint-1.60.3-linux-amd64.tar.gz && \
mv ./golangci-lint-1.60.3-linux-amd64/golangci-lint /usr/local/bin/golangci-lint && \
chmod +x /usr/local/bin/golangci-lint && \
# Install air
wget --no-verbose https://github.com/cosmtrek/air/releases/download/v1.52.3/air_1.52.3_linux_amd64.tar.gz && \
tar -xzf air_1.52.3_linux_amd64.tar.gz && \
mv ./air /usr/local/bin/air && \
chmod +x /usr/local/bin/air
# Go to the app dir, delete the temporary dir and create backups dir
WORKDIR /app
RUN rm -rf /app/temp && \
mkdir /backups && \
chmod 777 /backups
##############
# START HERE #
##############
# Add the startup script on every bash session
COPY scripts/startup.sh /usr/local/bin/startup.sh
RUN echo "\n\n" >> /root/.bashrc && \
cat /usr/local/bin/startup.sh >> /root/.bashrc
# Command just to keep the container running
CMD ["tail", "-f", "/dev/null"]