diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 38ecd15..2e30baf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -36,26 +36,15 @@ jobs: - name: Build and push uses: docker/build-push-action@v2 with: + file: Dockerfile push: true tags: | n1try/wakapi:latest + n1try/wakapi:alpine n1try/wakapi:${{ env.GIT_TAG }} ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:alpine ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }} platforms: linux/amd64,linux/arm64 - cache-from: type=registry,ref=n1try/wakapi:buildcache - cache-to: type=registry,ref=n1try/wakapi:buildcache,mode=max - - - name: Build and push (Alpine) - uses: docker/build-push-action@v2 - with: - file: Dockerfile.alpine - push: true - tags: | - n1try/wakapi:latest-alpine - n1try/wakapi:${{ env.GIT_TAG }}-alpine - ghcr.io/${{ github.repository }}:latest-alpine - ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-alpine - platforms: linux/amd64,linux/arm64 cache-from: type=registry,ref=n1try/wakapi:buildcache-alpine cache-to: type=registry,ref=n1try/wakapi:buildcache-alpine,mode=max diff --git a/Dockerfile b/Dockerfile index 5bc07b5..c601c1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,15 @@ # Build Stage -FROM golang:1.16 AS build-env +FROM golang:1.16-alpine AS build-env WORKDIR /src +# Required for go-sqlite3 +RUN apk add gcc musl-dev + ADD ./go.mod . RUN go mod download -RUN curl "https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh" -o wait-for-it.sh && \ +RUN wget "https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh" -O wait-for-it.sh && \ chmod +x wait-for-it.sh ADD . . @@ -25,12 +28,10 @@ RUN cp /src/wakapi . && \ # to override config values using `-e` syntax. # Available options can be found in [README.md#-configuration](README.md#-configuration) -FROM debian +FROM alpine:3 WORKDIR /app -RUN apt update && \ - apt install -y ca-certificates && \ - rm -rf /var/lib/apt/lists/* +RUN apk update && apk add bash ca-certificates tzdata && rm -rf /var/cache/apk # See README.md and config.default.yml for all config options ENV ENVIRONMENT prod @@ -48,4 +49,4 @@ COPY --from=build-env /app . VOLUME /data -ENTRYPOINT ./entrypoint.sh +ENTRYPOINT /app/entrypoint.sh diff --git a/Dockerfile.alpine b/Dockerfile.alpine deleted file mode 100644 index c601c1e..0000000 --- a/Dockerfile.alpine +++ /dev/null @@ -1,52 +0,0 @@ -# Build Stage - -FROM golang:1.16-alpine AS build-env -WORKDIR /src - -# Required for go-sqlite3 -RUN apk add gcc musl-dev - -ADD ./go.mod . -RUN go mod download - -RUN wget "https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh" -O wait-for-it.sh && \ - chmod +x wait-for-it.sh - -ADD . . -RUN go build -o wakapi - -WORKDIR /app -RUN cp /src/wakapi . && \ - cp /src/config.default.yml config.yml && \ - sed -i 's/listen_ipv6: ::1/listen_ipv6: /g' config.yml && \ - cp /src/wait-for-it.sh . && \ - cp /src/entrypoint.sh . - -# Run Stage - -# When running the application using `docker run`, you can pass environment variables -# to override config values using `-e` syntax. -# Available options can be found in [README.md#-configuration](README.md#-configuration) - -FROM alpine:3 -WORKDIR /app - -RUN apk update && apk add bash ca-certificates tzdata && rm -rf /var/cache/apk - -# See README.md and config.default.yml for all config options -ENV ENVIRONMENT prod -ENV WAKAPI_DB_TYPE sqlite3 -ENV WAKAPI_DB_USER '' -ENV WAKAPI_DB_PASSWORD '' -ENV WAKAPI_DB_HOST '' -ENV WAKAPI_DB_NAME=/data/wakapi.db -ENV WAKAPI_PASSWORD_SALT '' -ENV WAKAPI_LISTEN_IPV4 '0.0.0.0' -ENV WAKAPI_INSECURE_COOKIES 'true' -ENV WAKAPI_ALLOW_SIGNUP 'true' - -COPY --from=build-env /app . - -VOLUME /data - -ENTRYPOINT /app/entrypoint.sh