-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: Enable multi-stage Dockerfile * build: Optimize docker-compose for developer * build: Expose port of postgres in docker-compose.yml * build: Extended Dockerfile to include develop and prod build with multistages * ci: 🔧 Add new github action workflow for automated release * docs: Adjusted README to document development * docs: Added installation guide for different production setups
- Loading branch information
1 parent
0d7e8c9
commit 624aee4
Showing
10 changed files
with
296 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
READMETEMPLATE.md | ||
README.md | ||
|
||
# git | ||
.git | ||
**/.git | ||
.gitattributes | ||
.gitignore | ||
|
||
# Node | ||
## Logs | ||
logs | ||
*.log | ||
assets/npm-debug.log* | ||
assets/yarn-debug.log* | ||
assets/yarn-error.log* | ||
|
||
## Dependency directories | ||
assets/node_modules/ | ||
|
||
## Misc files | ||
.tool_versions | ||
elixir_buildpack.config | ||
phoenix_static_buildpack.config | ||
README.md | ||
LICENSE |
2 changes: 1 addition & 1 deletion
2
.github/workflows/ci_cd.yml → ...rkflows/on_push_branch__execute_ci_cd.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Do not forget to change status badge in ./README.md | ||
name: ci_cd | ||
name: on_push_branch__execute_ci_cd | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: on_push_tag_build_publish_release | ||
|
||
on: | ||
workflow_dispatch: | ||
docker_tag: | ||
description: "Define the docker tag name. You can define the docker tag version separately" | ||
default: mindwendel | ||
docker_tag_version: | ||
description: "Define the docker tag version" | ||
required: true | ||
push: | ||
tags: | ||
- "*.*.*" | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to GitHub Packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setting vars for later access | ||
id: set_vars | ||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | ||
|
||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GH_CONTAINER_REGISTRY_PERSONAL_ACCESS_TOKEN }} | ||
|
||
- name: Push to GitHub Packages | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ format('ghcr.io/mindwendel/mindwendel:{0}', steps.set_vars.outputs.tag) }} | ||
|
||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
FROM elixir:1.11-alpine | ||
|
||
RUN apk add --update-cache \ | ||
postgresql-client \ | ||
nodejs npm | ||
ARG ALPINE_VERSION=3.13 | ||
|
||
FROM elixir:1.11-alpine as elixir_alpine | ||
|
||
RUN apk add --update-cache postgresql-client nodejs npm | ||
|
||
RUN mix do local.hex --force, local.rebar --force | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN mix local.hex --force | ||
RUN mix local.rebar --force | ||
RUN mix deps.get | ||
|
||
FROM elixir_alpine as development | ||
|
||
RUN mix do deps.get, compile | ||
RUN npm --prefix assets install | ||
RUN mix compile | ||
|
||
RUN ["chmod", "+x", "./entrypoint.sh"] | ||
ENTRYPOINT ["sh", "./entrypoint.sh"] | ||
ENTRYPOINT ["sh", "./entrypoint.sh"] | ||
|
||
|
||
# Building a release version | ||
# https://hexdocs.pm/phoenix/releases.html | ||
FROM elixir_alpine AS build | ||
|
||
# Set build ENV | ||
ENV MIX_ENV=prod | ||
|
||
# Install mix dependencies | ||
RUN mix do deps.get, deps.compile | ||
|
||
# Build assets | ||
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error | ||
RUN npm run --prefix ./assets deploy | ||
RUN mix phx.digest | ||
|
||
# compile and build release | ||
RUN mix do compile, release | ||
|
||
# prepare release image | ||
FROM alpine:${ALPINE_VERSION} AS app | ||
RUN apk add --no-cache openssl ncurses-libs postgresql-client | ||
|
||
WORKDIR /app | ||
|
||
RUN chown nobody:nobody /app | ||
|
||
USER nobody:nobody | ||
|
||
COPY entrypoint.release.sh /app/entrypoint.release.sh | ||
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/mindwendel ./ | ||
|
||
ENV HOME=/app | ||
|
||
ENTRYPOINT ["sh", "./entrypoint.release.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.