diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 53f2575..dba286d 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,6 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Build the Unified Docker image + run: docker build . --file Dockerfile --tag albertoxamin/bang:latest - name: Build the Backend Docker image run: cd backend;docker build . --file Dockerfile --tag albertoxamin/bang-backend:latest - uses: actions/checkout@v2 @@ -14,5 +16,5 @@ jobs: run: cd frontend;docker build . --file Dockerfile --tag albertoxamin/bang-frontend:latest - name: Log into registry run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - - name: Push iamges - run: docker push albertoxamin/bang-backend:latest; docker push albertoxamin/bang-frontend:latest + - name: Push images + run: docker push albertoxamin/bang:latest; docker push albertoxamin/bang-backend:latest; docker push albertoxamin/bang-frontend:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e63da3d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:lts-alpine as builder +COPY ./frontend . +RUN npm install +RUN npm run build +FROM python:3.7-slim-stretch +COPY --from=builder ./dist /dist/ +COPY ./backend /dist/ +WORKDIR /dist +RUN pip install -r requirements.txt +EXPOSE 5001 +ENTRYPOINT ["python", "/dist/__init__.py"] \ No newline at end of file diff --git a/backend/__init__.py b/backend/__init__.py index 09b72c2..a26b998 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -8,7 +8,9 @@ from players import Player sio = socketio.Server(cors_allowed_origins="*") app = socketio.WSGIApp(sio, static_files={ - '/': {'content_type': 'text/html', 'filename': 'index.html'} + '/': {'content_type': 'text/html', 'filename': 'index.html'}, + '/css': './css', + '/js': './js', }) games: List[Game] = [] diff --git a/frontend/src/main.js b/frontend/src/main.js index 6de3e24..f2ac9a5 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -5,7 +5,7 @@ Vue.config.productionTip = false import VueSocketIO from 'vue-socket.io' Vue.use(new VueSocketIO({ debug: Vue.config.devtools, - connection: Vue.config.devtools?'http://localhost:5001':'http://bang.xamin.it:5001', + connection: Vue.config.devtools ? 'http://localhost:5001' : window.location.origin, })) new Vue({