chore(Dockerfile): build and deploy via Docker, remove Nixpacks
This commit is contained in:
parent
f85f47bbd4
commit
c9015a7f2b
7 changed files with 81 additions and 19 deletions
64
Dockerfile
Normal file
64
Dockerfile
Normal file
|
@ -0,0 +1,64 @@
|
|||
FROM node:21
|
||||
|
||||
# install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
openssh-client \
|
||||
rsync \
|
||||
curl \
|
||||
php-cli \
|
||||
php-mbstring \
|
||||
php-xml \
|
||||
jq \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# set working directory
|
||||
WORKDIR /workdir
|
||||
|
||||
# build time args
|
||||
ARG GIT_REPO
|
||||
ARG GIT_BRANCH=main
|
||||
|
||||
# clone source
|
||||
RUN git clone --depth 1 --branch ${GIT_BRANCH} ${GIT_REPO} app
|
||||
|
||||
# move into app directory
|
||||
WORKDIR /workdir/app
|
||||
|
||||
# build-time env vars
|
||||
ARG POSTGREST_API_KEY
|
||||
ARG POSTGREST_URL
|
||||
|
||||
# export vars for build staps
|
||||
ENV POSTGREST_API_KEY=${POSTGREST_API_KEY}
|
||||
ENV POSTGREST_URL=${POSTGREST_URL}
|
||||
|
||||
# clean npm cache
|
||||
RUN npm cache clean --force
|
||||
|
||||
# install node deps
|
||||
RUN npm install
|
||||
|
||||
# install php deps
|
||||
RUN curl -sS https://getcomposer.org/installer | php && \
|
||||
mv composer.phar /usr/bin/composer && \
|
||||
chmod +x /usr/bin/composer
|
||||
|
||||
RUN composer install --no-dev --optimize-autoloader
|
||||
|
||||
# build
|
||||
RUN npm run build
|
||||
|
||||
# set runtime env vars
|
||||
ARG SERVER_IP
|
||||
ENV SERVER_IP=${SERVER_IP}
|
||||
|
||||
# deploy and manage container healthcheck
|
||||
CMD bash -c "\
|
||||
mkdir -p ~/.ssh && \
|
||||
echo \"${SSH_PRIVATE_KEY}\" > ~/.ssh/id_rsa && \
|
||||
chmod 600 ~/.ssh/id_rsa && \
|
||||
ssh-keyscan -H \"${SERVER_IP}\" >> ~/.ssh/known_hosts && \
|
||||
rsync -avz --delete dist/ root@\"${SERVER_IP}\":/var/www/coryd.dev/ && \
|
||||
echo \"✅ Deployed successfully\" && \
|
||||
tail -f /dev/null"
|
Loading…
Add table
Add a link
Reference in a new issue