diff --git a/.github/workflows/dev-image.yml b/.github/workflows/dev-image.yml index e550dce..4ceaf2e 100644 --- a/.github/workflows/dev-image.yml +++ b/.github/workflows/dev-image.yml @@ -23,7 +23,7 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Docker Buildx (build) + name: Docker Buildx (build amd64 arm64) run: | docker buildx build \ --cache-from "type=local,src=/tmp/.buildx-cache" \ @@ -31,9 +31,9 @@ jobs: --platform linux/amd64,linux/arm64 \ --output "type=image,push=false" \ --tag albertoxamin/bang:dev \ - --file ./Dockerfile-armv7 ./ + --file ./Dockerfile ./ - - name: Docker Buildx (build) + name: Docker Buildx (build armv-7) run: | docker buildx build \ --cache-from "type=local,src=/tmp/.buildx-cache" \ @@ -41,7 +41,7 @@ jobs: --platform linux/arm/v7 \ --output "type=image,push=false" \ --tag albertoxamin/bang:dev \ - --file ./Dockerfile-armv7 ./ + --file ./Dockerfile ./ - name: Login to DockerHub uses: docker/login-action@v1 @@ -56,7 +56,7 @@ jobs: --platform linux/amd64,linux/arm/v7,linux/arm64 \ --output "type=image,push=true" \ --tag albertoxamin/bang:dev \ - --file ./Dockerfile-armv7 ./ + --file ./Dockerfile ./ - name: Inspect image run: | diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8c53638..e1e8d95 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -23,12 +23,22 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Docker Buildx (build) + name: Docker Buildx (build amd64 arm64) run: | docker buildx build \ --cache-from "type=local,src=/tmp/.buildx-cache" \ --cache-to "type=local,dest=/tmp/.buildx-cache" \ - --platform linux/amd64,linux/arm/v7 \ + --platform linux/amd64,linux/arm64 \ + --output "type=image,push=false" \ + --tag albertoxamin/bang:latest \ + --file ./Dockerfile ./ + - + name: Docker Buildx (build armv-7) + run: | + docker buildx build \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --platform linux/arm/v7 \ --output "type=image,push=false" \ --tag albertoxamin/bang:latest \ --file ./Dockerfile ./ @@ -39,11 +49,11 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Docker Buildx (push) + name: Docker Buildx (push all) run: | docker buildx build \ --cache-from "type=local,src=/tmp/.buildx-cache" \ - --platform linux/amd64,linux/arm/v7 \ + --platform linux/amd64,linux/arm64,linux/arm/v7 \ --output "type=image,push=true" \ --tag albertoxamin/bang:latest \ --file ./Dockerfile ./ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d84f4b7..255bfc5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,12 +1,53 @@ name: Test Pull requests on: pull_request: + jobs: - test_build: + buildx: runs-on: ubuntu-latest - env: - DOCKER_BUILDKIT: '1' steps: - - uses: actions/checkout@v2 - - name: Build the Unified Docker image - run: docker build . --file Dockerfile + - + name: Checkout + uses: actions/checkout@v2 + - + name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + - + name: Cache Docker layers + uses: actions/cache@v2 + id: cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - + name: Docker Buildx (test build amd64) + run: | + docker buildx build \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --platform linux/arm64 \ + --output "type=image,push=false" \ + --tag albertoxamin/bang:test \ + --file ./Dockerfile ./ + - + name: Docker Buildx (test build arm64) + run: | + docker buildx build \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --platform linux/arm64 \ + --output "type=image,push=false" \ + --tag albertoxamin/bang:test \ + --file ./Dockerfile ./ + - + name: Docker Buildx (test build armv-7) + run: | + docker buildx build \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --platform linux/arm/v7 \ + --output "type=image,push=false" \ + --tag albertoxamin/bang:test \ + --file ./Dockerfile ./ diff --git a/Dockerfile b/Dockerfile index 954c892..401fabe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,23 @@ +# build Vue frontend FROM node:lts-alpine as builder COPY ./frontend . RUN npm install RUN npm run build -FROM python:3.7.10-slim-stretch +# now we should have a dist folder containing the static website + +FROM python:3.7.10-stretch as pybuilder +WORKDIR /code +COPY ./backend /code/ +RUN pip install --user -r requirements.txt +# We get the dependencies with the full python image so we can compile the one with missing binaries + +FROM python:3.7.10-slim-stretch as app +# copy the dependencies from the pybuilder +COPY --from=pybuilder /root/.local /root/.local +# copy the backend python files from the pybuilder +COPY --from=pybuilder /code /dist +# copy the frontend static files from the builder COPY --from=builder ./dist /dist/ -COPY ./backend /dist/ WORKDIR /dist -RUN pip install -r requirements.txt EXPOSE 5001 ENTRYPOINT ["python", "/dist/__init__.py"] diff --git a/Dockerfile-armv7 b/Dockerfile-armv7 deleted file mode 100644 index e711af1..0000000 --- a/Dockerfile-armv7 +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:lts-alpine as builder -COPY ./frontend . -RUN npm install -RUN npm run build - -FROM python:3.7.10-stretch as pybuilder -WORKDIR /code -COPY ./backend /code/ -RUN pip install --user -r requirements.txt - -FROM python:3.7.10-slim-stretch as app -COPY --from=pybuilder /root/.local /root/.local -COPY --from=pybuilder /code /dist -COPY --from=builder ./dist /dist/ -WORKDIR /dist -EXPOSE 5001 -ENTRYPOINT ["python", "/dist/__init__.py"] diff --git a/README.md b/README.md index 06c18e1..bee2b63 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ # bang + +This is the repo for the PewPew! game, which is a replica of BANG!. +BANG! is a trademark owned by DVGiochi. + +[Frontend Readme](./frontend/README.md) + +[Backend Readme](./backend/Readme.md) \ No newline at end of file