wip(ci): docker dev and prod build + ci
This commit is contained in:
33
.github/workflows/build_docker.yml
vendored
Normal file
33
.github/workflows/build_docker.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
name: Build and Push Docker Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
jobs:
|
||||||
|
topos:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
context: .
|
||||||
|
# based on branch push tag latest for main with commit sha
|
||||||
|
tags: yassinsiouda/topos:latest, yassinsiouda/topos:main-${{ github.sha }}
|
||||||
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
FROM node:lts-alpine as dev
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./ /app
|
||||||
|
|
||||||
|
# install dependencies
|
||||||
|
RUN yarn install
|
||||||
|
|
||||||
|
# Run dev
|
||||||
|
ENTRYPOINT [ "yarn", "run", "dev" ]
|
||||||
|
|
||||||
|
FROM node:lts-alpine as build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# copy node modules from dev stage
|
||||||
|
COPY --from=dev /app/ /app/
|
||||||
|
|
||||||
|
# build
|
||||||
|
RUN yarn run build
|
||||||
|
|
||||||
|
FROM nginx:alpine as prod
|
||||||
|
|
||||||
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||||
18
docker-compose.yml
Normal file
18
docker-compose.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
version: '3.7'
|
||||||
|
services:
|
||||||
|
topos-dev:
|
||||||
|
container_name: topos-dev
|
||||||
|
profiles: ["dev"]
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: "dev"
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
topos-prod:
|
||||||
|
container_name: topos-prod
|
||||||
|
profiles: ["prod"]
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: "prod"
|
||||||
|
ports:
|
||||||
|
- "8001:80"
|
||||||
@ -4,7 +4,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite --host",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
@ -42,4 +42,4 @@
|
|||||||
"zifferjs": "^0.0.32",
|
"zifferjs": "^0.0.32",
|
||||||
"zzfx": "^1.2.0"
|
"zzfx": "^1.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user