-
Notifications
You must be signed in to change notification settings - Fork 164
Automatically build docker images #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Publish Docker image | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Save tag in env variable | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Save repo in env variable | ||
run: echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV | ||
|
||
- name: Print release and repo name for debugging | ||
run: | | ||
echo $RELEASE_VERSION | ||
echo $REPO_NAME | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: | | ||
restic/${{ env.REPO_NAME }}:latest | ||
restic/${{ env.REPO_NAME }}:${{ env.RELEASE_VERSION }} | ||
platforms: linux/amd64,linux/arm/v7 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
FROM alpine | ||
FROM golang:alpine3.13 AS builder | ||
LABEL stage=builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that label necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well no, it is a label. I wanted to make clear that this step is only needed for building the software. But I can delete it if you want. |
||
WORKDIR /workspace | ||
COPY . . | ||
RUN CGO_ENABLED=0 go build -o rest-server ./cmd/rest-server | ||
|
||
|
||
FROM alpine:3.13 AS final | ||
WORKDIR /app | ||
|
||
ENV DATA_DIRECTORY /data | ||
ENV PASSWORD_FILE /data/.htpasswd | ||
ENV PATH="/app:${PATH}" | ||
|
||
RUN apk add --no-cache --update apache2-utils | ||
|
||
COPY docker/create_user /usr/bin/ | ||
COPY docker/delete_user /usr/bin/ | ||
COPY docker/entrypoint.sh /entrypoint.sh | ||
COPY rest-server /usr/bin | ||
COPY docker/. . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific need to change the location where the helper scripts / entrypoint.sh are stored? I've been bitten a few times by container updates which "just" changed a few paths, but caused my derived containers to break. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just my personal preference: Having all the additional stuff in the same location. But that is no "must". There also doesn't seem to be a best practice for that - so I can do it the way you want. |
||
COPY --from=builder /workspace/rest-server . | ||
|
||
VOLUME /data | ||
EXPOSE 8000 | ||
|
||
CMD [ "/entrypoint.sh" ] | ||
CMD [ "./entrypoint.sh" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to pin alpine releases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reproducible builds and best practice. But here also: Not really needed, so can be reverted if preferred in the original way.