-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4a119d
commit f32700f
Showing
2 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ env: | |
SERVER_IP: 'swis.sh' | ||
DEPLOY_PATH: '/home/swissh/swis.sh/' | ||
DOCKER_IMAGE: 'swissh-app' | ||
CONTAINER_PORT: '8091' | ||
|
||
on: | ||
push: | ||
|
@@ -22,7 +23,10 @@ jobs: | |
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t ${{ env.DOCKER_IMAGE }} . | ||
DOCKER_BUILDKIT=1 docker build \ | ||
--progress=plain \ | ||
--no-cache \ | ||
-t ${{ env.DOCKER_IMAGE }} . | ||
- name: Set up SSH agent | ||
uses: webfactory/[email protected] | ||
|
@@ -31,6 +35,7 @@ jobs: | |
|
||
- name: Add SSH Key to Known Hosts | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "$(ssh-keyscan -t rsa ${{ env.SERVER_IP }} 2>/dev/null)" >> ~/.ssh/known_hosts | ||
- name: Save Docker image | ||
|
@@ -43,13 +48,31 @@ jobs: | |
- name: Deploy using Docker | ||
run: | | ||
ssh ${{ env.SERVER_USER }}@${{ env.SERVER_IP }} << 'EOF' | ||
set -e | ||
cd ${{ env.DEPLOY_PATH }} | ||
# Load the new image | ||
docker load < image.tar.gz | ||
# Stop and remove the old container | ||
docker stop ${{ env.DOCKER_IMAGE }} || true | ||
docker rm ${{ env.DOCKER_IMAGE }} || true | ||
docker run -d --name ${{ env.DOCKER_IMAGE }} \ | ||
# Run the new container with port 8091 mapped to container's port 80 | ||
docker run -d \ | ||
--name ${{ env.DOCKER_IMAGE }} \ | ||
-p 8091:80 \ | ||
--restart unless-stopped \ | ||
${{ env.DOCKER_IMAGE }} | ||
# Verify the container is running | ||
if ! docker ps | grep -q ${{ env.DOCKER_IMAGE }}; then | ||
echo "Container failed to start" | ||
docker logs ${{ env.DOCKER_IMAGE }} | ||
exit 1 | ||
fi | ||
# Clean up | ||
rm image.tar.gz | ||
docker image prune -f | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
# Build stage | ||
FROM oven/bun:1 as builder | ||
WORKDIR /app | ||
|
||
# Copy and install dependencies first | ||
COPY package.json bun.lockb ./ | ||
RUN bun install | ||
RUN bun install --no-cache | ||
|
||
# Copy source code | ||
COPY . . | ||
RUN bun run build | ||
|
||
# Debug: Show what's being built | ||
RUN echo "Content of src directory:" && ls -la src/ | ||
|
||
# Add verbose logging to build | ||
RUN bun run build || (echo "Build failed. Showing error details:" && ls -la && exit 1) | ||
|
||
# Production stage | ||
FROM nginx:alpine | ||
COPY --from=builder /app/.output/public /usr/share/nginx/html | ||
WORKDIR /usr/share/nginx/html | ||
|
||
# Copy built files | ||
COPY --from=builder /app/.output/public . | ||
COPY --from=builder /app/.output/server /app/server | ||
COPY nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
# Use standard Nginx port | ||
EXPOSE 80 | ||
|
||
# Add healthcheck | ||
HEALTHCHECK --interval=30s --timeout=3s \ | ||
CMD wget -q --spider http://localhost:80/ || exit 1 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |