1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: drop debian based docker image and use alpine by default

This commit is contained in:
Ferdinand Mütsch 2021-12-15 15:35:51 +01:00
parent d6aa2c4405
commit 7dd0967451
3 changed files with 11 additions and 73 deletions

View File

@ -36,26 +36,15 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
file: Dockerfile
push: true push: true
tags: | tags: |
n1try/wakapi:latest n1try/wakapi:latest
n1try/wakapi:alpine
n1try/wakapi:${{ env.GIT_TAG }} n1try/wakapi:${{ env.GIT_TAG }}
ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:alpine
ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }} ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}
platforms: linux/amd64,linux/arm64 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-from: type=registry,ref=n1try/wakapi:buildcache-alpine
cache-to: type=registry,ref=n1try/wakapi:buildcache-alpine,mode=max cache-to: type=registry,ref=n1try/wakapi:buildcache-alpine,mode=max

View File

@ -1,12 +1,15 @@
# Build Stage # Build Stage
FROM golang:1.16 AS build-env FROM golang:1.16-alpine AS build-env
WORKDIR /src WORKDIR /src
# Required for go-sqlite3
RUN apk add gcc musl-dev
ADD ./go.mod . ADD ./go.mod .
RUN go mod download 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 chmod +x wait-for-it.sh
ADD . . ADD . .
@ -25,12 +28,10 @@ RUN cp /src/wakapi . && \
# to override config values using `-e` syntax. # to override config values using `-e` syntax.
# Available options can be found in [README.md#-configuration](README.md#-configuration) # Available options can be found in [README.md#-configuration](README.md#-configuration)
FROM debian FROM alpine:3
WORKDIR /app WORKDIR /app
RUN apt update && \ RUN apk update && apk add bash ca-certificates tzdata && rm -rf /var/cache/apk
apt install -y ca-certificates && \
rm -rf /var/lib/apt/lists/*
# See README.md and config.default.yml for all config options # See README.md and config.default.yml for all config options
ENV ENVIRONMENT prod ENV ENVIRONMENT prod
@ -48,4 +49,4 @@ COPY --from=build-env /app .
VOLUME /data VOLUME /data
ENTRYPOINT ./entrypoint.sh ENTRYPOINT /app/entrypoint.sh

View File

@ -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