diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9c1f26d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +/bin/ +/.shards/ +/bruno/ +/spec/ +/sqlite/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cd05847 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM alpine:edge as base +WORKDIR /usr/src/app + +RUN apk add crystal shards sqlite-dev openssl-dev + +FROM base AS build +ENV ENV=production +COPY . . + +RUN shards install +RUN shards build --progress + +FROM base AS release +COPY --from=build /usr/src/app/bin/migrate . +COPY --from=build /usr/src/app/bin/url-shortener . +COPY --from=build /usr/src/app/bin/cli . + +EXPOSE 4000/tcp +CMD ["./url-shortener"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..171b11e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + app: + build: . + environment: + ENV: production + DATABASE_URL: sqlite3://./sqlite/data.db?journal_mode=wal&synchronous=normal&foreign_keys=true + APP_URL: http://0.0.0.0:4001 + ports: + - 4001:4001