test(dockerfile & workflow): added spacings for secrets, optimized Dockerfile
This commit is contained in:
parent
a7d3ec6719
commit
edd75a7127
3 changed files with 37 additions and 28 deletions
|
|
@ -82,10 +82,10 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
# Begin setting up SSH w/ Secrets
|
# Begin setting up SSH w/ Secrets
|
||||||
install -m 600 -D /dev/null ~/.ssh/${{ secrets.DEPLOY_USER }}
|
install -m 600 -D /dev/null ~/.ssh/${{ secrets.DEPLOY_USER }}
|
||||||
echo "${{ secrets.DEPLOY_KEY }}" | base64 -d > ~/.ssh/${{ secrets.DEPLOY_USER }}
|
echo ${{ secrets.DEPLOY_KEY }} | base64 -d > ~/.ssh/${{ secrets.DEPLOY_USER }}
|
||||||
ssh-keyscan -H -p ${{ secrets.DEPLOY_PORT }} ${{ secrets.DEPLOY_HOST }} > ~/.ssh/known_hosts
|
ssh-keyscan -H -p ${{ secrets.DEPLOY_PORT }} ${{ secrets.DEPLOY_HOST }} > ~/.ssh/known_hosts
|
||||||
|
|
||||||
printf "Host deploy\nPort ${{ secrets.DEPLOY_PORT }}\nHostname ${{ secrets.DEPLOY_HOST }}\nIdentityFile ~/.ssh/${{ secrets.DEPLOY_USER }}\nUser ${{ secrets.DEPLOY_USER }}" > ~/.ssh/config
|
printf "Host deploy\nPort ${{ secrets.DEPLOY_PORT }} \nHostname ${{ secrets.DEPLOY_HOST }} \nIdentityFile ~/.ssh/ ${{ secrets.DEPLOY_USER }} \nUser ${{ secrets.DEPLOY_USER }}" > ~/.ssh/config
|
||||||
unset DOCKER_HOST
|
unset DOCKER_HOST
|
||||||
docker context create deploy --docker "host=ssh://deploy"
|
docker context create deploy --docker "host=ssh://deploy"
|
||||||
docker context use deploy
|
docker context use deploy
|
||||||
|
|
|
||||||
73
Dockerfile
73
Dockerfile
|
|
@ -1,39 +1,48 @@
|
||||||
# TODO: Plan for docker-compose.yml, create a script on run.bash to wait for .env file to run
|
# TODO: Plans:
|
||||||
# the application
|
# Multi-stage builds, seperating building frontend & pre-requisites
|
||||||
|
|
||||||
|
# NOTE: Frontend setup
|
||||||
|
FROM node:25-alpine AS frontend-build
|
||||||
|
|
||||||
|
WORKDIR /app/frontend
|
||||||
|
|
||||||
|
COPY frontend/package.json frontend/package-lock.json ./
|
||||||
|
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
COPY frontend/ .
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# NOTE: Backend setup
|
||||||
|
FROM node:25-alpine AS backend-build
|
||||||
|
|
||||||
|
RUN apk add --no-cache python3 py3-pip
|
||||||
|
|
||||||
|
WORKDIR /app/api
|
||||||
|
|
||||||
|
COPY api/requirements.txt ./
|
||||||
|
|
||||||
|
RUN python3 -m venv --copies venv
|
||||||
|
|
||||||
|
ENV PATH="/app/api/venv/bin:$PATH"
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir -U -r requirements.txt
|
||||||
|
|
||||||
|
COPY api/src src/
|
||||||
|
|
||||||
|
|
||||||
|
# Actual setup
|
||||||
FROM node:25-alpine
|
FROM node:25-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN <<EOF
|
RUN apk add --no-cache bash python3
|
||||||
apk update
|
|
||||||
apk add --no-cache python3 bash py3-pip
|
|
||||||
EOF
|
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-c"]
|
COPY --from=frontend-build /app/frontend frontend
|
||||||
# NOTE: Frontend setup
|
COPY --from=backend-build /app/api api
|
||||||
COPY frontend/package.json frontend/package-lock.json ./frontend/
|
COPY start.bash .
|
||||||
WORKDIR /app/frontend
|
|
||||||
RUN npm ci && npx next telemetry disable
|
|
||||||
|
|
||||||
# NOTE: Backend setup
|
|
||||||
WORKDIR /app/api
|
|
||||||
COPY api/requirements.txt ./
|
|
||||||
RUN python3 -m venv venv
|
|
||||||
ENV PATH="/app/api/venv/bin:$PATH"
|
|
||||||
RUN <<EOF
|
|
||||||
pip install --no-cache-dir -U -r requirements.txt
|
|
||||||
pip install -U pip
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# NOTE: Copy rest of the source code
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
WORKDIR /app/frontend
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
EXPOSE 8000
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
ENTRYPOINT ["bash", "/app/start.bash"]
|
ENTRYPOINT ["bash", "/app/start.bash"]
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ echo "$@"
|
||||||
if [[ $1 == "web" ]]; then
|
if [[ $1 == "web" ]]; then
|
||||||
cd ./frontend/ && npm run start
|
cd ./frontend/ && npm run start
|
||||||
elif [[ $1 == "api" ]]; then
|
elif [[ $1 == "api" ]]; then
|
||||||
cd ./api/ && source venv/bin/activate && cd ./src && fastapi run
|
cd ./api/src && source ../venv/bin/activate && fastapi run
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue